Git revert - git request parent1 or parent2

I am trying to get back the last commit made in a branch (by someone else). I am using the TortoiseGit client. When I click Undo Changes Parent1 , git offers two options: Parent1 and Parent2 . What does it mean? What is Parent1 and what is Parent2?

screenshot

+7
git tortoisegit
source share
2 answers

Each commit in git has at least one parent (except for the first / initial commit). The commit parent is the previous one.

 C1 <- C2 <- C3 

C1 is the initial commit. C2 is the second. C1 is the parent of C2. The same goes for C3.

Merger approval is a special fix in terms of the number of parents.

 C1 <- C2 <- C3 \ .. C4 <- C5 <- C6 

C6 - merge lock. He has two parents: C3 and C5. If you combined the two branches (commits) when you were on C5: C5 is considered parent 1 (first parent), and C3 - parent 2 (second parent).

+3
source share

It looks like you are trying to get a merge commit back in your branch. A merge has two parents, one for each branch involved in the merge. You need to select the parent version of the story that you want to keep. You must check each parent and decide which one you want to keep. Most likely, you probably want to keep the parent commit that appears in the php7 branch. This should be the Parent 1 option in the drop-down list.

 php7 A -- B -- M <-- retain this parent version of history / master .. C 
+3
source share

All Articles