Reverting a git merge while allowing for the same merge later)

Sorry to say that you have wasted your branch.

But there is a workaround. The trick is to “rewrite” the merge commit temporarily so that it forgets that the branch is a parent. Assume X is the merge commit:

git replace --graft X X^   # pretend that there is just one parent
git merge branch           # merge the branch again
git replace --delete X     # remove the replacement

Leave a Comment