Reverting merge

103 Views Asked by At

How do I revert a merge ?

I see referring to the parent id. How do we get the parent ID such as those mentioned in Git revert merge to specific parent ?

How do we get the number ?

git revert -m 1 0ce2ca0b35f59af267241cf4d40d16a3e13ba6f3
2

There are 2 best solutions below

0
VonC On

You can do a

git show --format="%P" <SHA>

If your HEAD is the result of a merge:

git show --format="%P" HEAD

You can also display directly the SHA1 of each parent:

git rev-parse <SHA>^1
git rev-parse <SHA>^2

See also this old thread about "merge revert".

0
MrPickles7 On

git revert {head#} -m {number of commits backwards you wish to revert}

After -m you just put a number like 2 or 1, for me I can't specify the exact commit number. Then a gui will come up and show what commit you're targeting to revert to is.

Head# is the actual {git number} 0ce2ca0 you wish to revert from.