why some git commits are older than their parent?
I have had a couple of other similar observations.
How can I explain them?
2 Solutions collect form web for “why some git commits are older than their parent?”
Commit history in git is rewritable. There are many ways that that could have happened. The most likely way is that the commit was rebased after it was created.
You can change git history with an interactive rebase, e.g.:
git rebase --interactive|-i HEAD~(number of commits)
Here is the scenario:
$ git commit -m 'Commit 1' $ git commit -m 'Commit 2' $ git rebase -i HEAD~2 // changing only 'Commit 1' edit bae2ea4 Commit 1 pick 0e25612 Commit 2 $ git add . $ git commit --amend $ git rebase --continue
After these ‘Commit 2’ will be older than its parent ‘Commit 1’
You should remember that you are not advised to rewrite history after your changes were published (pushed).