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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Pull Requests merged unexpectedly

I had three open pull requests open, all to 'development'. Two were a PR by another user and one was my own.

My local copy of development was behind, so I pushed it to the remote. The act of pushing from development local to my development remote to unexpectedly caused two of the open PRs to merge automatically into development.

This was very much not wanted because there are outstanding problems to fix in those PRs. And one of the PRs was set to require approval which it had not been given.

What might have caused this? Are there criteria for automatic merging?

3 answers

2 accepted

2 votes
Answer accepted

Hello @ade,

Thanks for reaching out.

A pull request can be merged automatically if its source branch is directly or indirectly merged into the target branch externally, i.e. if the source branch tip commit becomes reachable from the tip of the target branch.

Here's a simple example:

/ . .
/ . .

Letters are commits, and let's say there're three branches here:

  • branch master is at C
  • branch b1 is at E, and there's a pull request targeting master – dots represent pull requests (please excuse my poor ASCII graphics)
  • branch b2 branched off E and is now at F, and there's also a pull request targeting master

Now, if pull request F → master is merged first, pull request E → master will be merged automatically because all commits from b1 are now reachable from master, i.e. there's no difference between b1 and master anymore.

Similar thing will happen if someone creates a merge commit with same consequences locally and then pushes it up to Bitbucket – all affected pull requests will be automatically merged.

Does this make sense?

Let me know if you have any questions.


Yes this makes total sense. Good to know!

2 votes
Answer accepted

@ade, are you sure that your local copy of development was behind? If so, you would have wanted to pull from the remote, rather than push because if it was behind, that means the server had commits that you did not.

It's a bit hard to tell what the exact state of everything was when you pushed, so the below is a little on the general side, but most of it should be applicable.

That the pull requests were merged implies that your local copy of development contained the commits that were on the source branches of those pull requests. The reason this circumvents the pull request merge checks is because those merge checks are run when a pull request is merge is started (which is stopped if any of the merge checks veto the merge), however a push to a branch will not trigger those checks.

To improve this workflow and avoid changes being pushed to your development branch outside of the pull request workflow, you can set up a Branch Permission (available in repository settings) to disallow changes to that branch except for pull requests. Then when a remote push is attempted it will be blocked.

Hope this helps.



John van der Loo
Developer, Bitbucket Server

Jimmy Seddon Community Leader Oct 10, 2019

Hey @ade

I agree with the assessment of both @John van der Loo and @Daniil Penkin.

This really sounds like your local development branch contains the commits of the pull requests that had not been merged until you pushed them to the remote.

Much like John has said setting up branch permissions to require a pull request will prevent users from manually pushing to the remote.

We have this setup up ourselves with an exception in place for our admin group in case of emergencies.

You might be interested to read more about branch permissions here:


Like ade likes this

Thanks all, and yes – to clarify – I switched to a different development machine which had an already checked out copy of development which both was behind my "other" copy of development but git also was saying it was ahead. So I pulled then pushed.

I think yes, I must have previously pulled some commits from the branch (the source of the PR) into this local copy by accident (or forgetting that I had done that). And then carelessly pushed that rather than stopping to ask why it was ahead!

Anyway, yes thanks @Jimmy Seddon I am familiar with branch permissions, they are excellent! In fact I had to turn off the limitation on "rewriting history" in order to fix the situation using a "RESET head" then a "push with force" option.

In this situation given it is the development branch I do allow myself as manager of the project to manually push to this branch, but not the rest of the team. Unfortunately with great power comes great responsibility etc *oops*

Our "master" is updatable by PR only (we use branch permissions for that).

Jimmy Seddon Community Leader Oct 10, 2019

Hey @ade,

I've had a couple of oops myself, so not to worry it happens to the best of us!


Like ade likes this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

2,124 views 0 7
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you