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.
Hi @Simran,
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.