I accidentally did git commit --amend
instead of git commit -c ORIG_HEAD
after a git reset HEAD~
(as seen on the answer "Undo a commit and redo"), and as a result I seem to have a branched timeline. (I don't know the correct term.) Also, GitHub is showing the amended commit with a timestamp of when I made the amendment, not the original commit.
That is to say, I get this from git log --graph --all
:
* commit eea7f50e03fe35013b4f8c31f99b392b90406d3c
| Author: Author <name@example.com>
| Date: Wed Jan 26 19:42:00 2022 +0000
|
| Commit made after mistake
|
* commit de775e988b88453ce13eb874c19f29d878e7b0f9
| Author: Author <name@example.com>
| Date: Wed Oct 19 20:37:02 2016 +0000
|
| Penultimate old commit
|
| * commit 9c419983e4554803ee9b61b0d45661de8dd1297f
| | Author: Author <name@example.com>
| | Date: Wed Oct 19 20:38:01 2016 +0000
| |
| | Final old commit
| |
| * commit f5212efa5b2149a00541e0bf67de9f9995817c47
|/ Author: Author <name@example.com>
| Date: Wed Oct 19 20:37:02 2016 +0000
|
| Penultimate old commit
|
* commit b42e879cd92f3b7b7038546413859e4f9f9497d4
| Author: Author <name@example.com>
| Date: Mon Aug 24 23:49:22 2015 +0000
|
| Even older commit
|
What do I need to do to:
- Correctly amend "Penultimate old commit" with the contents of "Final old commit", maintaining its original timestamp;
- Get rid of the newer copy of "Penultimate old commit";
- Have the latest commit follow on from it?