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

Antonio Anzivino May 31, 2016

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

0 votes
Pavel Komarov September 19, 2017

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.

Pavel Komarov October 24, 2017

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.

Like # people like this
0 votes
Prasath Chandramohan November 21, 2016

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

0 votes
Lubo September 15, 2016

Definitely!

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

0 votes
Antonio Anzivino September 15, 2016

Worth pushing this to BBSERV Jira?

0 votes
Lubo September 15, 2016

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events