Avoid conflicts by reverting reverts

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the git category.

Last Updated: 2021-05-15

I merged in a feature branch rewrite_checkout to master but then was hit by a bug in production that I wanted to address before this big feature deploy. So I reverted the feature merge with git revert -m 1 SHA.

(FYI: -m 1 means "mainline 1", which means "the branch that was merged into" - i.e. go back to the old master. Compare to -m 2)

So far no surprises.

Later on, when the feature was ready, I merged in this same (already merged but since reverted) branch git merge rewrite_checkout, but got tons of surprising conflicts about stuff that should have already been resolved.

The solution was to undo the revert commit - to revert the revert. Then I had zero conflicts.


If you reverted a merge on a branch, then later try to merge in the same branch again, you will get a mess unless you revert the revert.