Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do you resolve conflicts with a protected branch?

szilberberg July 7, 2016

I have a master branch (protected from deletions, overwrites, and merging without pull requests) and I have an unprotected feature branch which I need to merge into master. Our policy is that we ONLY merge branches into master, we will never commit into master.

 

Right now I have a pull request for the feature branch to be pulled into master but Bitbucket says I have conflict with one of the files. The procedure given from Bitbucket is to essentially fix it by merging the branch locally into master and fixing it that way. I CAN'T DO THIS because of our policy.

 

What is an alternate way to fix my merge conflict without interacting with the master branch?

 

I have tried checking out the conflicted file into my feature branch and fixing the merge there, but that doesn't help.

1 answer

1 accepted

2 votes
Answer accepted
Tim Crall
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2016

An alternative is to pull master, and locally merge master into your feature branch and resolve conflicts locally (or, better yet, rebase the feature branch off of master and resolve conflicts).  Then push the feature branch.

The downside to this that has been pointed out before when I've suggested it is that it can bring commits into the feature branch from master that you might now want in that branch. On workflows where the feature branch is disposable after merging, this isn't a big problem.

The other alternative is to pull master branch, create a conflict_resolution branch off of master, merge the feature branch into conflict_resolution, push, and then do a Pull Request from conflict_resolution into master.

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2016

I would go with option 1. Resolve conflicts on feature branch. As long as the code on master is clean, there shouldn't be any problem in the code that comes through. But I can understand the concern!

Tim Crall
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2016

I agree, but on another recent, very similar question where I gave that answer, the concern was raised, so this time I thought I'd mention it.

Tim Crall
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 7, 2016

On another note, I'd personally suggest, when following option 1, to do a rebase rather than a merge.

git pull master
git checkout feature/xyz
git rebase master
<resolve conflicts>
git push
szilberberg July 7, 2016

Thank you so much for your responses! 

 

@Tim Crall I am going to go with your last suggestion where you make a conflict resolution branch. Rebasing is dangerous for my company because people are pulling and merging things where they really shouldn't so I want to stay away from rebasing just in case.

 

I also like this option because I think it is easier to explain to someone else (which I am going to have to do). Thanks for your input and speedy response!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events