We are using Bitbucket cloud and our master branch is protected to disallow any direct pushes.
Once the pull request is approved, Is there a CLI command that can be used to merge the pull request? This is because we would like to increment the version in the master branch right before the merge operation.
Is there a way to allow only specific branches to merge to the master branch?
Also, we are NOT using bitbucket pipelines.
Welcome to Atlassian Community!
No, there is no specific Git command that would allow you to bypass the protection that you have set up in Bitbucket. By design Git does not care about permissions. The only way around it would be to allow specific users to merge to your master branch.
And there is nothing in Bitbucket that you can configure to only allow merges from specific branches. You could probably do it with git hooks, but you would have to add those hooks to each client and make sure they are updated whenever you make a change to the hook.
I would like to expand on @Mikael Sandberg 's response.
1. If you have an existing pull request to master in Bitbucket you can merge it with the following REST API command https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/pullrequests/%7Bpull_request_id%7D/merge . Restricting commits to master to be only pull request merges is a good idea. Even if someone merges to master locally - they cannot push the changes to remote (Bitbucket)
2. As far as I know there is no technical option to limit the branches you can merge FROM to master. The best way I can think of is to limit the number of users that can merge to master via branch permissions, and then trust those users to adhere to the merge policy.
Let me know if I can help in any other way.
Kind regards, Ulrich
Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...
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