5

My colleague pushed his commit to our github repository. Unfortunatlley he has system date set to some 20 days ahead of the real time. So all (4) his commits have wrong date. I would like to change the dates in these commits, but some additional work is already done based on these wrong-dated commits.

I found this SO question: How can one change the timestamp of an old commit in Git? , which answers show how I can do it, but I dont think it is safe as the commit SHAs will be changed beacuse of teh date change and I am not sure what will happen to the changes which were based on the original (wrong-dated) commits.

So, is it safe to change the dates and push the changed commits? What will exactly happen in the github repository? I presume completely new commtis will be created and the old ones will still be there anyway ...

On other hand if I leave the wrong-dated commits as tehy are now, what is the danger? So far I just noticed that the network graph on github does not work ...

4

1 回答 1

1

您可以更改将导致新历史记录的提交。您可以让 GitHub 接受git push --force将更改历史记录的更改。但是,这样做会给从 repo 中提取的其他开发人员带来麻烦(他们可能不得不重新克隆它)。

历史是基于 SHA 的,而不是它们发生的时间。如果您在执行 a 之后查看日期,rebase您将看到发生在“之后”后续日期之后的更改。因此,就 repo 或您的代码的问题而言,没有危险。

于 2013-05-03T15:35:53.857 回答