I recently rebased my most recent commits to my master branch interactively (rebase -i
). I squashed multiple commits into just two, discarding unneeded commit messages (fixup
), and subsequently pushed to remote master (on GitHub).
What I noticed is that the commit dates in the remote repo does not correspond to the date of the commit (as provided by git log
). Rather the commit dates on the remote branch correspond to the date of rebasing and pushing. From what I can find, the commit history on the remote repo is supposed to correspond to the local one, but the commit dates in my remote and local branch are divergent. I can only assume this has something to do with rebasing, and that my original commits where tampered with.
git log
:% git log
commit 09e76b90aa1c0c3f6a780c8b29b0c93dc2f57143 (HEAD -> master, origin/master)
Author: John Doe <john@doe.com>
Date: Wed Apr 12 13:23:12 2023 +0200
1st imputation success no interaction or random sl
commit 2ef860eabd90dfff5197c66a3dbb541174e1146b
Author: John Doe <john@doe.com>
Date: Thu Mar 9 22:32:49 2023 +0800
First commit on Arch Linux
It's talking about commit dates, and the output from log shows author date. If you showed the commit dates in log, you would see that there is a match. Try with git log --pretty=fuller
With regards to the second question:
In order to change the commit dates to correspond to author dates, git rebase has --committer-date-is-author-date
for this purpose. Rebase with the added flag and then force-pushing to remote resolved the issue for this particular case.
Code example:
git rebase --committer-date-is-author-date HEAD~2
git push -f origin master