What happens if you merge two branches that have identical commits?

Viewed 981

I have two different branches that share some identical commit changes, meaning the same content but distinct commits performed on each branch.

If I were to merge these two branches, what happens to these identical changes? Does Git consider this a merge issue? If not, how does Git decide which commit becomes the "owner" of the identical change?

1 Answers

If the changes are the same coming from different branches, git will keep it as it is in both branches, so no conflict. Now, about the owner, what do you mean? The author? Well, when git is tracking where lines came from (git blame) my hunch is that it will check the parents in the order that they show up in the merge revision... so if it sees that a line is present in the first parent, it will take that as the path that has to be followed in order to blame the line.

By the way, when merging, git won't consider the revisions that make up each one of the branches..... like to see if the revisions are present in both branches. It will, in simplified terms, check how the branches differ in content since their last common ancestor. So, it could be 100 revisions on one branch and only one revision in the other, if the changes are the same, well, git keeps a single copy of them and no conflict is generated.

Related