Regarding howto/revert-a-faulty-merge.txt - another way to revert a merge
- From
Noam Yorav-Raphael <noamraph@gmail.com>
- Date
- Jun 24, 2024, 10:17 UTC
- Message-ID
- <CAO8o=D5womGcsVsGT4h2=3qry05mMrd9dFDkZHrLtPCDw0+2Tg@mail.gmail.com>
Hi,
I was looking for a way to revert a merge, and found the document at howto/revert-a-faulty-merge.txt. It basically suggests that if you reverted a merge and want to re-merge, you should first revert the revert.
This is fine, but it means that you must remember to revert the revert before the next merge, which may be hard to remember. I thought of another solution: In the source branch, add a commit reverting all the changes since the previous merge, then merge again from that brange to the master branch, and then revert the revert. In a diagram:
----o---o---o---M---o---o------------W-------
/ / /
------o---A---B---C-------!C!B!A---o----ABC--(`!C!B!A` means a commit that reverts C, B and A, returning to `o`. `ABC` means a commit that applies A, B and C, thus returning to the tree after C.)
Now the W commit really reverts the M commit, and you can forget about it.
Would you be interested in a patch adding this to howto/revert-a-faulty-merge.txt?
Thanks, Noam