I need to do a git revert -m , but I have not been able to find any documentation on how the commit parents are numbered. Everything I’ve seen (including the help pages for rev-parse) just tells me that the parents are numbered but do not say how they are numbered. Could someone point out to me where this is defined and how to determine this?
Share
will give you the parent SHAs of the given commit in numerical order. Most often the one you’ll want to specify for
git revertwill be1.In the case of most merges, the SHA of the branch that was checked out will be the first parent, and the SHA of the branch that was merged in will be the second. (Basically, the checked out branch is always the first parent; the other parents are the branches that were specified to the merge command in the order of their specification.)
If you want to find the SHA for a particular parent, use the caret operator:
git rev-parse <SHA>^1git rev-parse <SHA>^2et cetera.