1

I have following branches on my local:

  1. master
  2. branch-a
  3. branch-b
  4. branch-c
  5. dev

I created PR (Pull Request) for branch-a (PRA-1), branch-b (PRB-1), branch-c (PRC-1). My colleagues finished reviewing my code. Since I know that branch-a, branch-b, branch-c are going to conflict each other, I create a conflict-resolution branch.

I base conflict-resolution from master and continue to merge branch-a, branch-b, branch-c while resolving any conflicts. Then once all of them are complete, I merge this conflict-resolution branch into branch-a, branch-b, branch-c.

Now that my initial pull request is code reviewed, I want my colleagues to review conflict-resolution for branch-a (PRA-2), branch-b (PRB-2) and branch-c (PRC-2) in their respective second pull requests.

halfer
  • 19,824
  • 17
  • 99
  • 186
Yamin Noor
  • 53
  • 4
  • You may merge branch-b and branch-c into branch-a and re-ask a code review. Why do you want another branch to resolve conflict ? – Samuel Dauzon Aug 26 '15 at 07:53
  • I don't want to merge everything to master. So I thought I'd create an intermediary branch to resolve conflicts and then merge this branch to each individual branch (a/b/c). My goal is to have conflict resolved code in my branch-a, branch-b, branch-c branches. – Yamin Noor Aug 26 '15 at 15:39
  • But your 3 branches will have the same version of your project. That's what you want or you want only one branch with merge of branch a, branch b and branch c ? – Samuel Dauzon Aug 27 '15 at 07:15
  • You are right. I'll have the same version of my project. Hmm, now that you've mentioned, I'm thinking how can I keep my branch changes and also bring just the conflict resolved part into each & individual branch. Ok this is what I want: **branch-a** should have its own changes and just the part needed not to conflict with others. Same goes for **branch-b** & **branch-c**. So that I can merge any of these branches into master without having conflicts. – Yamin Noor Aug 27 '15 at 19:27
  • In any case, if master changed you may have conflict when you merge others branches. – Samuel Dauzon Aug 27 '15 at 20:51
  • Do my answer helps you ? – Samuel Dauzon Aug 28 '15 at 21:05
  • Yes I think it does make sense. – Yamin Noor Aug 28 '15 at 23:13
  • 1
    If it solves your problem could you validate my answer ? – Samuel Dauzon Aug 29 '15 at 23:56

1 Answers1

0

If you want, you can use git rerere (https://git-scm.com/blog/2010/03/08/rerere.html and http://git-scm.com/docs/git-rerere). This commands let you save conflict resolutions for done again the resolution when you want. So, in order to save the conflict resolution you must merge your three branches in master branch. But you don't want because you wait for this merge. I advise these steps :

Enable git rerere cache with :

git config --global rerere.enabled true

Create new branch from master

git checkout master
git branch resolution_branch

Merge and resolve conflicts of the three branches

git merge branch-A
# You resolve conflict

git merge branch-B
# You resolve conflict

git merge branch-C
# You resolve conflict

Now, when you will merge these branches Git will resolve conflict. However, You must to add file to index for explicit resolution. If you want that Git add automaticaly file in the index :

git config --global rerere.autoupdate true
Samuel Dauzon
  • 10,744
  • 13
  • 61
  • 94