Pushing a manual merge for a conflicting pull request on a protected branch

We use Bitbucket server at our company.

 

Today it happened that a multi-merge pull request (branch->stable->master, as we have a production branch set) failed on the stable->master part because of conflicts.

 

Nothing to worry. Bitbucket opens another pull request automatically to merge missing changes from stable to master branch.

The problem is that since I have set branch permissions to allow modifications to master branch only via pull requests I am unable to follow Bitbucket's instructions for manual merge

 

Bitbucket asks me to do the following:

 

Automatic merge failed because 
there were conflicts. You must resolve the conflicts by merging 
downstream only i.e. merging the source branch into the target branch.
Step 1: Fetch the changes (saving the source branch as FETCH_HEAD).
git fetch origin stable

Step 2: Checkout the target branch and merge in the changes from the source branch. Resolve conflicts.
git checkout master
git merge FETCH_HEAD


Step 3: After the merge conflicts are resolved, stage the changes accordingly, commit the changes and push.
git commit
git push origin HEAD


Step 4: The pull request will be updated and marked as merged.

Ok, but when I try to push the changes to master branch I get a fancy error message:

remote:                             *%%%%%.
remote:                         %%%         %%%
remote:                      ,%#               %%
remote:                     %%                   %%
remote:                    %#                     %%
remote:                   %%                       %
remote:                   %(                       %%
remote:                   %%%%%%%%%%%%%%%%%%%%%%%%%%%
remote:                 %#%*%#///////%# %%///////%%%%%%
remote:                ,% %*%%******%#   %%******%(%%,%
remote:                  %%/ %%/**%%/%%%%%%%(**#%( %%#
remote:                   %%          %%%          %(
remote:                    %                      .%
remote:                    *%        %%%%%       .%
remote:                      %#                 %%
remote:                       .%%            .%%
remote:                       .%%.%%,     %%%.%%/
remote:                 %%%%%%##%.  #%%%%%.  .%((%%%%%%
remote:             %%#(((((((((%%,         #%%(((((((((#%%.
remote:       %%%((((((((((((((((((%%%, .%%%((((((((((((((((((#%%*
remote:     %%(((((((((((((((((((((((((%(((((((((((((((((((((((((#%.
remote:   ,%(((((((((((((((((((((((((((((((((((((((((((((((((((((((%#
remote:   %#((((((((((((((((((((((((((((((((((((((((((((((((((((((((%
remote:   %%%%%%%%%%%%%(((((((((((((((((((((((((((((((((%%%%%%%%%%%%%
remote:  %%            %####((((((###%%%%%%%%#(((((((((%            ,%
remote: ,%             %%%%%%#.               %%%((((((%*            %%
remote: #%                                       %%%#                %%
remote: .%                             .%%%%%%%%%                    %#
remote:  %                         #%%%                              %
remote:  %                     %%%%                                  %*
remote: /%************/#%%%%%%######%%*                        ..,*/(%%
remote:               %%######(((((((##################%%
remote:               %%######(((((((((((((((((((((((((%%
remote: //////////////%%%%%%%%#########################%%/////////  ///
remote: ----------------------------------------------------
remote: Branch refs/heads/master can only be modified through pull requests.
remote: Check your branch permissions configuration with the project administrator.
remote: ----------------------------------------------------
remote:

I am forced to push to another (temporary) branch from which to open a pull request.

 

Shouldn't Bitbucket server implement a check that allows direct pushing to a protected branch (with respect to other permissions, e.g. only me and few coworkers can modify the master branch) if that push merges an open pull request?

 

Or am I doing something wrong?

5 answers

I have exactly same issue. This looks to me like a bug. Are there any news or nobody cares?

Worth pushing this to BBSERV Jira?

Definitely!

The permissions say: "Prevent changes without a pull request", but pull request is there! It just requires manual merge.

same issue here. BB should allow manual merge if there is a conflict and satisfies pre hook/merge check

0 votes

I had this same issue and was able to fix it by following the instructions up to the point where it said to git push origin HEAD and instead pushing to my feature branch with git push origin <feature-branch>. The pull request was updated, and all went as it should. The problem is that following the instructions leaves HEAD on the protected development branch.

Update: I ran in to this issue again, and my prior solution didn't work, because git believed the feature branch was up to date with all the changes I made in the development branch (which were without exception simply accepting the feature branch's versions).

But I found a different workaround: Don't check out the origin development branch and then pull from the feature branch, merge in development and try to push to the feature branch. Instead stay in the feature branch, pull from the development branch, merge there, and then push the results up to the feature branch.

The pull request gets updated, and you don't see the angry ASCII guardian because you're never trying to push to a protected branch.

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

649 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot