本文介绍了我如何忽略在提交时提交时区信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 最近,我分发了一个由github托管的存储库,贡献者遍布世界各地,并发现每个提交日志都包含提交者的时区信息。 2013-11-07 02:31:41 +0545 2013-11-04 12:58:36 -0600< - 这个提交者住在CST或厄瓜多尔或Chili或... 2013-10-31 10:36:36 +0700 - - 这个提交者住在印度尼西亚,泰国或蒙古,老挝或澳大利亚或... : 我知道可以通过编辑输出表单来隐藏(例如: git:时区和时间戳格式),但这隐藏了github的存储库中实际保存的内容,仅从我的眼中。每个提交者的时区肯定保存在github的服务器中。 所以我的问题: 为什么提交者的时区需要提交?它是干什么用的? UTC时间不够吗? 提交时是否有任何忽略我电脑时区设置的选项?我不想将我的电脑的时区设置为UTC,只因为git是隐式提交的。 解决方案> 您可以使用此命令在UTC时间提交: git commit --date =`date - utc +%Y-%m-%dT%H:%M:%S%z` 您还可以将其替换为方便的名称: git config --global alias.commitutc'!git commit --date =$(date --utc +%Y-%m-%dT%H:%M:%S%z)' 并且执行 git commitutc 。 有关更详细的解释,请查看此博文。 Recently, I forked a repository hosted by github, with contributors spreading all over the world, and found out that the each commit log contains committer's timezone information.2013-11-07 02:31:41 +0545 <-- This committer is living in Nepal. Surely.2013-11-04 12:58:36 -0600 <-- This committer is living in CST or Ecuador or Chili or ...2013-10-31 10:36:36 +0700 <-- This committer is living in Indonesia or Thai or Mongolia or Laos or Australia or ...:I know it's possible to hide this by editing the output form (e.g. git: timezone and timestamp format), but this hides what's actually saved in github's repository, only from my eye. Each committer's timezone is surely saved in github's server.So my questions:Why are committer's timezone needed for commits? What is it used for? Isn't UTC time enough?Are there any options to ignore MY computer's timezone setting when committing? I don't want to set my computer's timezone to UTC, only because git is implicitly committing it. 解决方案 You can use this command to commit in UTC time:git commit --date="`date --utc +%Y-%m-%dT%H:%M:%S%z`"You can also alias it to a convenient name:git config --global alias.commitutc '!git commit --date="$(date --utc +%Y-%m-%dT%H:%M:%S%z)"'And do git commitutc.For a more detailed explanation take a look at this blog post. 这篇关于我如何忽略在提交时提交时区信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-01 17:10