9 Oct 2014

GIT - reverting a merge

Why try best to avoid it?
TL;DR. precaution is better than cure.
For example, think about what reverting a merge (and then reverting the
revert) does to bisectability. Ignore the fact that the revert of a revert
is undoing it - just think of it as a "single commit that does a lot".
Because that is what it does. When you have a problem you are chasing down, and you hit a "revert this
merge", what you're hitting is essentially a single commit that contains
all the changes (but obviously in reverse) of all the commits that got
merged. So it's debugging hell, because now you don't have lots of small
changes that you can try to pinpoint which _part_ of it changes. 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
Source: https://www.kernel.org/pub/software/scm/git/docs/howto/revert-a-faulty-merge.txt

The article also explains in detail about options available when you fall into such situations that you will have to revert anyway.

No comments:

Post a Comment