I've heard that a git merge done with the --no-ff flag preserves full history making it easier to pull out a specific merge. I've not seen it explained, though, how to undo a merge made with --no-ff. Also, I can't see how it makes it easier to unmerge than a fast-forward merge. Can someone shed some light on this, or point me to some good info on this?
Thanks.
You can revert all commits made by the fast forward merge (--no-ff):
git revert SHA_OF_MERGE_COMMIT0944694980cc3dfcf4c2f9a99c3aadbfa47811ee -m 1
the most important here is a key -m 1
-m parent-number
--mainline parent-number
Usually you cannot revert a merge because you do not know which side of the merge should be considered the mainline. This option specifies the parent number (starting from 1) of the mainline and allows revert to reverse the change relative to the specified parent.
Reverting a merge commit declares that you will never want the tree changes brought in by the merge. As a result, later merges will only bring in tree changes introduced by commits that are not ancestors of the previously reverted merge. This may or may not be what you want.
See the revert-a-faulty-merge How-To for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With