How to prevent merging of one branch to another

Is there a way to prevent merging of one branch to another. We have branches like 15-maint 16-maint master, we merge forward from 15-maint to 16-maint and also from 16-maint to master but never from 16-maint to 15-maint or from master to 16-maint. Sometimes due to human error, of the person merging, higher branch is merged to lower - like 16-maint to 15-maint or master to 16-maint. Is there any way to prevent this by means of hooks or configs in Bitbucket ?

1 answer

0 votes

Hi Bopanna

You can use branch level permissions and a branch naming convention to limit who has the capability to merge. Take a look at the documentation available at



@Bhushan Nagaraj : Thankyou for the documentation link. But It does not provide the option to achieve what I am asking...

@b bopanna would you please elaborate why branch permissions won't work for you? 

@Ulrich Kuhnhardt [Izymes]: There are 4 restrictions available :

i. Prevent all changes

ii. Prevent deletion

iii. Prevent rewriting history

iv. Prevent changes without a pull request

Now how can I use these to configure my lower branches to not allow merges from higher ? (do not permit merge of master to 16-maint while allowing merging of 15-maint to 16-maint ?)

I'm looking for the solution similar to the issue posted here. How can I restrict committers from merging `any branch` -> `master` except `develop` branch.

Use cases:

* prevent from merging feature/bugfix/.. branches to master

* except develop to master


Can anyone help to achieve this using bitbucket.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 14, 2019 in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder :  #!/bin/bash source "$(dirname "$0")/" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

237 views 0 12
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