【问题标题】:Is possible change the commit date on git? [duplicate]是否可以更改 git 上的提交日期? [复制]
【发布时间】:2014-02-02 10:54:09
【问题描述】:

当我提交我的工作时,电脑日期是 02/13/2014,但正确的日期是 01/13/2014。是否可以将更改提交日期更改为正确的日期?

【问题讨论】:

  • 如果你的commit已经在公共场所,比如被push了,那么一般来说,你不应该改变它,因为这会导致这些其他仓库的混乱。

标签: git


【解决方案1】:

如果是你的最新提交:

git commit --amend --date="Wed Jan 13 12:00 2014 +0100"

例如,如果是您的最后 5 次提交,您可以进行交互式 rebase 并编辑提交:

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

记住这个rewrites history

【讨论】:

  • 请记住,这会改写历史。
  • @Abizern 正确,更新的答案。
  • @Abizern:字面意思。
  • @BenjaminBannier 微妙。我喜欢。 :)
  • 到底谁希望他们能改写历史......?
猜你喜欢
  • 2016-02-08
  • 2012-09-22
  • 2018-04-25
  • 2020-07-06
  • 2012-11-22
  • 2021-10-16
  • 2012-10-13
  • 2017-06-01
  • 1970-01-01
相关资源
最近更新 更多