-1

Trying to figure out what happens in particular cases when there are multiple branches and/or a fork off of a master branch and how that might cause conflicts.

Say I have the following case where black is the master branch, red is a branch, and green is a branch:

enter image description here

The green branch occurs after the red branch and is merged back into main before red. When red is merged - will there be conflicts?

Now say that red is a branch but green is a fork. Red branches before green is forked. Green has makes code changes and then sends a pull request to the master, who accepts and imports changes. the red merges back into main. Will there be conflicts in that case?

Thanks in advance.

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
Windstorm1981
  • 2,564
  • 7
  • 29
  • 57
  • 2
    It doesn't matter who is a branch and who is a fork. Merge is merge. Any time two people merge into the same branch there is always the potential for a merge conflict. That doesn't mean there will be one. Conflicts are about exactly what changed in each branch. You've given no information about that. You might want to read my https://www.biteinteractive.com/understanding-git-merge/ – matt Jun 13 '21 at 20:51

1 Answers1

1

The answer is neither yes nor no, but it depends.

A conflict occurs when two developers, regardeless of the branch in which they operate, change the same line of code, or a file is deleted by one, but changed by the other.

In this article at https://www.atlassian.com/git/tutorials/using-branches/merge-conflicts#:~:text=Conflicts%20generally%20arise%20when%20two,automatically%20determine%20what%20is%20correct.&text=Git%20will%20mark%20the%20file,and%20halt%20the%20merging%20process. you may find a lot of information about this topic.

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
  • 1
    Thanks for this. Will study. Does this imply that is it 'bad' to have 2+ people working off of a main branch in separate branches unless they are working on distinctly separate parts of the code because their changes to code could conflict when merged back? – Windstorm1981 Jun 13 '21 at 21:07
  • 1
    Nope.... it is OK for that to happen (2 people working on the same sections of code). Hey, conflicts are a part of a developer's life. Learn as best you can how to deal with them... and there are _a lot_ of things to consider in order to be able to solve conflicts _correctly_. I have written a little guide about the biggest pitfalls on the topic so if you don't mind: http://www.ezconflict.com/ No tracking, no monetization, no cookies, etc. – eftshift0 Jun 13 '21 at 21:25
  • @eftshift0 GREAT e-book. will be studying. – Windstorm1981 Jun 14 '21 at 12:19