Reputation: 4673
For instance I have a history like this
A -> B -> C -> F -> G ---------- feature
\
D -> E -------- master
Throughout the history I have a file a.txt with the first line in it, say, "sometext". On commit G I decide to remove "sometext" and leave the first line blank. Then I merge these two branches. A new commit is formed with the first line being blank. So E contains "sometext" line and G does not. So this is a difference between branches that are being merged. How does git decide what to include in merge commit? Is it because G was made after E ?
Upvotes: 1
Views: 30
Reputation: 67733
In this case, it will identify the common ancestor C
of both branches, and compare the changes since that ancestor on each branch C..G
vs C..E
.
Since C..E
doesn't touch the line, but C..G
does, G
's change is taken. If both branches changed the same line in different ways, it would ask you to resolve the conflict manually.
This is a 3-way merge: see this old question for some discussion, and the Merge Strategies section in the documentation for more merge options.
Upvotes: 3