0

I have a repository in github, which main branch is named master and the following situation:

  • A contribution of code in a PR (let's name PR-A) from branch feature/pr-a to master.
  • A contribution of code in a PR (let's name PR-B) from branch feature/pr-b to master.

Both PRs are independent so they could in theory to include incompatible changes that would cause a git conflict in some files.

Is there any simple or scripted way (*) of checking the potential conflict between both PRs/branches once merged in master? I mean, a way of answering the following questions:

  • If I merge first PR-A to master, would I get a conflict when I try to merge PR-B to master. Which files?
  • If I merge first PR-B to master, would I get a conflict when I try to merge PR-A to master. Which files?

Thanks in advance!

(*) Of course, I can always get this information doing the actual merge in my local copy and check, but I wonder if there is any other mechanism that doesn't need to do the actual merges.

fgalan
  • 11,732
  • 9
  • 46
  • 89

1 Answers1

1

You could get the changed file lists from the diff or cherry commands. You would then know if there are any files that are common to both. But just because the files are common does not mean git will flag a conflict unless the changes are close together (or overlapping of course) in the file. It may be enough to keep the teams alert and communicating, or it may be pointless in files with very high churn, such as monolithic resource files or help files.

You could simply create a new local branch from the master and try to merge the two working branches to there, and see what happens? That way you can easily just throw away that local branch.

But you could do the same just with a pull to local, not push anything and discard everything.

Gem Taylor
  • 5,381
  • 1
  • 9
  • 27