0

I have three branch Master, Test1, Test2 (Test 1 and Test 2 created from Master)

Now in Test1 branch, I have made some changes to a single file (like updating the method code and signature ) and then created a pull request to merge the same with Master.

I see there are no conflicts shown and it got merged successfully.

Now again in Test2 branch, I have made some changes to a single file (like updating the method code and signature ) and then created a pull request to merge the same with Master. This time I got the merge conflict error.

My question is: Why it has not shown any merge conflict in the first scenario while merging Test1 code to Master.

Under which exact scenario, we will be getting merge conflicts?

1 Answers1

0

A conflict happens when both branches have diverged from the last common ancestor between the two parts of the merge (let's ignore the case of octopus (more than 2 branches) merges in this context).

During your first PR, only one side has changed, the one in Test1. Straightforward merge.

However, when you make your second PR, master has already changed from the state it was in when Test2 has been created, so both parts are considered new to the last common ancestor.

To avoid this conflict on the second PR, you could (for example) have merged master in Test2 before making your PR. You would then have an up-to-date master, and the PR would find changes only on Test2 side.

Also, welcome to Stack Overflow o/

Romain Valeri
  • 19,645
  • 3
  • 36
  • 61