Skip to content

Instantly share code, notes, and snippets.

@SheldonWangRJT
SheldonWangRJT / Git - Revert a Merge.txt
Last active March 5, 2019 20:45
Git - Common Used Commands
Git - Revert a Merge
#iOSBySheldon
Reverting a commit is usually not hard, specially with the help of Source Tree, if, you are reverting a simple commit on a branch. What you need to do is just to right click the commit you want to revert and then choose "Reverse Commit".
However, if the commit you want to revert is a "Merge", it will be a little bit harder. If you do the same thing in Source Tree, right click - "Reverse Commit", it will give you an error that Source Tree cannot revert it because there are two branches involved.
Let's name the merge-from branch as "F" and "merge-to" branch as "T".
Here is the solution for it (only can be done in Terminal, at least today):