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

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 Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

26,415 views 26 12
Join discussion

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