Re-doing a reverted merge in Git

You have to “revert the revert”. Depending on you how did the original revert, it may not be as easy as it sounds. Look at the official document on this topic.

---o---o---o---M---x---x---W---x---Y
              /
      ---A---B-------------------C---D

to allow:

---o---o---o---M---x---x-------x-------*
              /                       /
      ---A---B-------------------C---D

But does it all work? Sure it does. You can revert a merge, and from a
purely technical angle, git did it very naturally and had no real
troubles.
It just considered it a change from “state before merge” to
“state after merge”, and that was it.
Nothing complicated, nothing odd,
nothing really dangerous. Git will do it without even thinking about it.

So from a technical angle, there’s nothing wrong with reverting a merge,
but from a workflow angle it’s something that you generally should try to
avoid
.

If at all possible, for example, if you find a problem that got merged
into the main tree, rather than revert the merge, try really hard to:

  • bisect the problem down into the branch you merged, and just fix it,
  • or try to revert the individual commit that caused it.

Yes, it’s more complex, and no, it’s not always going to work (sometimes
the answer is: “oops, I really shouldn’t have merged it, because it wasn’t
ready yet, and I really need to undo all of the merge”). So then you
really should revert the merge, but when you want to re-do the merge, you
now need to do it by reverting the revert.

Leave a Comment