When I commited my work, the pc date was 02/13/2014, but the correct date was 01/13/2014. Is possible the change commit date to the correct date?
Asked
Active
Viewed 1.4k times
17
-
like here? http://stackoverflow.com/questions/454734/how-can-one-change-the-timestamp-of-an-old-commit-in-git – x29a Jan 14 '14 at 11:38
-
If your commit already in public places, for example, be pushed, then generally speaking, you should not change it, because this will cause chaos in these other repositories. – Lee Duhem Jan 14 '14 at 12:24
1 Answers
31
If it is your latest commit:
git commit --amend --date="Wed Jan 13 12:00 2014 +0100"
If it is for example your 5th last commit, you can do an interactive rebase and edit the commit:
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
Keep in mind that this rewrites history.
-
3
-
1
-
1
-
-
13
-
I tried to avoid the `--amend` command by just committing it with a custom date in the first place. I did `git commit --date="Jun 11 2007"` and it said `Date: Tue Jun 12 00:01:04 2007 -0400 51 files changed, 13166 insertions(+)` but after pushing, the date is showing up as "1 minute ago" and a 2023 date on GitHub. – Nike Feb 09 '23 at 04:05
-
After running `git commit --amend --date="Jun 11 2007"` the push was rejected with a suggestion to run `git pull` first. After doing that, I was able to push, but the files on GitHub are still showing up as 2023 files. However my GitHub profile shows commits going all the way back to 2007 (I'm not sure if this happened after the first commit or after the `--amend` commit, but since it says "2 commits in 2007" it probably happened the first time.. but when I cluck on the hyperlink that says "2 commits", it says "no commits found"). – Nike Feb 09 '23 at 04:09
-
@Nike did you ever solve github not reflecting the local date change? – retrovius Aug 28 '23 at 18:20