2

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
Community
  • 1
  • 1
maan81
  • 3,469
  • 8
  • 36
  • 53

2 Answers2

0

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".

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

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.

MrPickles7
  • 654
  • 2
  • 10
  • 21