what happened:
change1,
git commit,
git push,
change2,
git commit
what should have happened:
change1,
git commit,
git push,
change2,
git commit –amend
It’s not important that I retain change2, but it is important that I am able to amend the original commit. How do I do this?
Since you have pushed it, be aware that this is tricky and you are rewriting history.
You can
git rebase -ito before the first commit and chooseeditfor the commit in the text that is presented to you. This way, you will be brought to the first commit state where you change / amend and then git will apply the next commit over it.Or you can
git reset --soft firstto go to first commit and amend it along with change2.Or
git reset --hard firstto go to the first commit and amend it without the change2