Preventing users to merge branches in Bitbucket/Stash

Hello Team,


My team consist of a number of developers who requires write access to branches named branch 1 and branch 2. Now sometimes, they mistakenly merges wrong branch to the wrong target. i.e, they are suppose to merge branch 1 to branch 2. What is the way to prevent users from merging branch 2 to branch 1. Or is there a way to make branch 2 a default one?


Warm Regards,


3 answers

0 votes
Mikael Sandberg Community Champion Jun 30, 2016

Are you using pull requests when merging between branch 1 and branch 2? You can change the default branch for a repository under settings > repository details. The default branch will be used as the target branch when you create a pull request. But it will not prevent a user from changing the target branch.

0 votes

You can make branch2 default in the repository settings. But there is no way to restrict the merges based on branches.

You can write plugins with hooks to prevent it on the server. But users will still be able to do it locally. The advantage and disadvantage of using git!

We're actually looking to do this very thing. Doing a google search I don't see any plugins that have this capability as well. Something I'm missing? Trying to not write our own plugin here if it's at all possible.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

698 views 5 10
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