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?
Commits in git can have multiple parents, aka 'merge commits'. Using them maintains the branch history. They don't maintain the branch name, or even the history of the branch: they just tell what are the parent commits of the commit; as mentioned above, this history can be a "lie".
When you git merge two commits (or branches, whatever) without fast-forwarding, a new commit will be created with both commits as parents. You can merge more than two commits in that way, so the new commit may have more than one parent.
A git commit can have an arbitrary number of parents. This can be the case, for example, when you use git merge to merge more than one commit into your current branch.
It is a three-way merge between:
git merge-base @^1 @^2
, ^1
being the first parent, ^2
being the second parent of HEAD: see "Ancestry Reference".)(you can see another example of three-way merge in this answer)
By convention, GitHub will always display the parents as:
Compared to the common ancestor of those two commits, the second one, when merged into the first one, brings 4 additions and 4 deletions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With