I have performed the following merge:
A---B---C---E (HEAD, merge of C and D)
/
D---|
But I noticed some issues in E, and fixed them in F:
A---B---C---E---F (HEAD)
/
D---|
I want to modify commit E so that it contains the "fixup" changes made in F.
When I try git rebase -p -i HEAD~2, it tries to create a regular (not merge) commit, and even tries to make me re-resolve the conflicts I already resolved when performing the merge for E.
How do I fixup commit E so it contains the changes made in F?
git reset --soft E
git commit --amend # (add --no-edit to keep the same commit message)
should be enough. It'll recreate a merge commit (with a different hash than E, let's call it E') while inserting whatever changes you made between E and F.
Note: If the changes you're squashing into the merge commit are really part of the merge, like fixing a faulty conflict resolution, all good. However, if not, this will create what is sometimes called an evil merge. Because it not only merges commits C and D, but also introduces "unrelated" changes. It doesn't "break" anything per se, but is generally frowned upon because it can confuse someone inspecting history in the future.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With