When a commit has multiple parents, like this one, we see that it has 4 additions and 4 deletions. My question is compared to what? Are the additions and deletions compared to the file as it existed in BOTH parents? Or how exactly is it compared?
Asked
Active
Viewed 7,069 times
12
Shamoon
- 38,429
- 77
- 269
- 518
-
1The parent which is **being** merged. https://github.com/ginatrapani/ThinkUp/pull/1974/files – hjpotter92 Aug 19 '14 at 13:26
-
How do you know which parent that is? – Shamoon Aug 19 '14 at 17:13
1 Answers
12
It is a three-way merge between:
- the common ancestor of both parents (
git merge-base @^1 @^2,^1being the first parent,^2being the second parent of HEAD: see "Ancestry Reference".) - the second parent (commit c0ce149) acting as source (being merge to)
- the first parent (commit 0994e7c) acting as destination (being on the branch where the merge occurs)
- with HEAD (commit 4cd713e) being the result of the merge.
(you can see another example of three-way merge in this answer)
By convention, GitHub will always display the parents as:
- The first parent, which is the branch you were on when you merged,
- and the second parent, which is the commit on the branch that you merged in.
Compared to the common ancestor of those two commits, the second one, when merged into the first one, brings 4 additions and 4 deletions.
-
is there any way of identifying whether each commit is a merge commit or are there are mulitple parents to that commit in github API level – Kasun Siyambalapitiya Apr 17 '17 at 12:00
-
From `man git-merge` it says that `git-merge - Join two or more development histories together` which may lead to multiple parent commits ( more than 2) for a certain commit. in that case how the stats are calculated – Kasun Siyambalapitiya Apr 17 '17 at 12:33
-
can you please have a look on this question http://stackoverflow.com/questions/43452249/how-to-indentify-which-commit-introduce-which-changes-in-a-octopuss-merge/43453033#43453033 – Kasun Siyambalapitiya Apr 18 '17 at 03:12
-
1