Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix GITHUB commit date?

I am working on a github hosted project. For testing reasons, I have to move my computer date to somewhere in the future (2012) and forgot to bring it back to normal time when doing a git commit / push.

The actual commit is now actually saved as 2012 instead of 2010 and it's screwing our github view since they always appear on top.

Is there any way to fix that?

like image 278
khelal Avatar asked Jul 11 '10 11:07

khelal


People also ask

How do I fix commit history?

There are many ways to rewrite history with git. Use git commit --amend to change your latest log message. Use git commit --amend to make modifications to the most recent commit. Use git rebase to combine commits and modify history of a branch.

Can I backdate a git commit?

You can always change a date on your computer, make a commit, then change the date back and push.

How do I reset a commit in GitHub?

Click History. Right-click the commit you want to revert and click Revert Changes in Commit.


1 Answers

If not too many people have already pulled from that GitHub repo, you could locally change the GIT_AUTHOR_DATE and GIT_COMMITTER_DATE of your old commit, and git push --force that to the GitHub repo.
(Just be prepared to point out people to the RECOVERING FROM UPSTREAM REBASE section of the git rebase man page)

See How can one change the timestamp of an old commit in Git? for the specifics on the git filter-branch command required for that kind of operation.

like image 73
VonC Avatar answered Sep 28 '22 00:09

VonC