Home > other >  How to correct bug in merge - squash fix commit to merge commit
How to correct bug in merge - squash fix commit to merge commit

Time:07-25

this should be probably very easy, but I am not able to solve it out. I introduced bug in the merge, and than I corrected it in additional commit. I would like to squash the "bug fix" commit to the merge commit so it looks like the bug was never there. (my changes are only local for now). But it seems to be impossible to squash another commit to merge commit.

Could someone tell me how this should be handled correctly? I know there is possibility to revert to state before the merge, but this way I would need to solve all the merge conflicts once again what I would like to avoid.

enter image description here

CodePudding user response:

from the command line :

git reset --soft HEAD~
git commit --amend

CodePudding user response:

You should be able to amend the merge commit by soft resetting on it, and adding your last commit content:

git reset --soft @~
git add .
git commit --amend --no-edit

This assumes your merge commit itself is local (not yet pushed)

CodePudding user response:

Doing this in IntelliJ is also possible. The process is exactly the same as VonC and LeGEC described already. The soft reset is available from the 'Show History' window. After resetting you open the regular commit window and check the 'Amend' checkbox on top. Please be aware, that when amending already pushed commits you need to force push afterwards.

  • Related