Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否可以更改git上的提交日期?_Git - Fatal编程技术网

是否可以更改git上的提交日期?

是否可以更改git上的提交日期?,git,Git,当我提交我的工作时,pc日期是2014年2月13日,但正确的日期是2014年1月13日。是否可以将提交日期更改为正确的日期?如果是您的最新提交: git commit --amend --date="Wed Jan 13 12:00 2014 +0100" 例如,如果这是您的第五次提交,您可以执行交互式重基并编辑提交: git rebase -i HEAD~5 <find the commit and change 'pick' to 'e', save and close file&g

当我提交我的工作时,pc日期是2014年2月13日,但正确的日期是2014年1月13日。是否可以将提交日期更改为正确的日期?

如果是您的最新提交:

git commit --amend --date="Wed Jan 13 12:00 2014 +0100"
例如,如果这是您的第五次提交,您可以执行交互式重基并编辑提交:

git rebase -i HEAD~5
<find the commit and change 'pick' to 'e', save and close file>
git commit --amend --date="Wed Jan 13 12:00 2014 +0100"
git rebase --continue
git-rebase-i头~5
git提交——修改——日期=“2014年1月13日星期三12:00+0100”
git rebase--继续吗

记住这个。

像这里吗?例如,如果您的提交已经在公共场所被推送,那么一般来说,您不应该更改它,因为这将导致这些其他存储库的混乱。请记住,这将重写历史。@Abizern更正,更新的答案。@Abizern:完全正确。@BenjaminBannier。我喜欢。:)谁不希望他们能改写历史。。。?