gitgit-rebasesquashgit-interactive-rebase

Rebase "fixup" commit into prior merge commit


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?


Solution

  • git reset --soft E
    git commit --amend
    

    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.