Branch Permissions - only allow commits via pull request

Is there a way to setup branch permissions to only allow commits to the master branch via pull requests?

I would like to configure our repository such that developers cannot directly commit to the master branch. They should be allowed to commit to feature branches, issue pull requests, and once approved merge the feature branch down to master.

The issue I am facing is that if permissions to commit to master are revoked, a developer is unable to click the 'merge' button to complete a pull request. Is there currently any way around this?

1 answer

1 accepted

2 votes

Unfortuantely, branch permissions do not support this workflow.

Please watch and vote on the JIRA for this feature: STASH-2910

There is a workaround, but it requires you to develop a Stash plugin (not as daunting as it may sound). You can write a pre-recieve hook (see our developer docs) that simply denies pushes to certain branches - your users will be forced to use a pull request.

Also see our blog on using code generation in AMPS - it will save you a lot of time and practically write the hook for you.


Thanks Matthew! This may work better in the long run as it would give developers the option to skip pre-commit hooks when necessary.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

1,953 views 1 5
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