Repository owners and administrators can set Branch management rules on a repository. Through these rules, you can enforce a project or team workflow. For example, owners or administrators can:
Understand the differences with Mercurial branch management
Unlike Git's single branch concept, Mercurial supports both bookmarks or named branches. For Mercurial repositories, support for branch management is slightly different. Bitbucket Cloud allows you to limit pushes for both bookmarks and named branches. You can only prevent the deletion of bookmarks; you cannot prevent deletion of named branches.
You cannot prevent history re-writes or rebasing in a Mercurial repository.
Using a repository's branch management settings
Each repository has Branch Management settings. To view these settings for a repository, log in under account with owner or administrative rights on the repository. Then, do the following:
- Select the repository settings button.
- Choose Branch management from the left-hand navigation.
Within this dialog, you can use the * (asterisk) to match multiple branches. Wildcards let you set up rules that apply across sets of branches. For example, a specification
PROJ-66, and so on.
Limit push powers
You can set rules that limit who can push to a branch. Rules specify the groups and/or users that can push to a branch. Any user that doesn't meet the rule can't push to a repository. You can only create rules for users and groups that have write permissions or higher. Bitbucket knows which users and groups this applies to; the dialog only shows you users and groups with this permission.
To prevent any user from pushing to a branch, you can, do this:
- Create a group called EmptyGroup on your account.
You can name the group anything you like. We recommend you choose a name that reflects how the group is used.
- Give the group write permissions.
- Go to the Branch Management page.
- Locate the Limit pushes to specific users and groups section.
- Limit pushes to a branch to the EmptyGroup group.
Users are free to interact with a branch in their local clone. When they attempt to push to the Bitbucket remote, users who aren't allowed to push to the branch receive a message that the remote rejected the push.
Prevent branch (bookmark) deletion
You can also prevent users from deleting branches (Git) or bookmarks (Mercurial). To do this, you simply list the branches (or bookmarks for Mercurial users) you want to keep.
You can use wildcards to match multiple branches (Git) or bookmarks (Mercurial).
Prevent history re-writes (Git only)
If the repository is a Git repository, you can prevent history re-writes (also known as a rebase). To do this, you simply list the branches you want to keep.
You can use wildcards to match multiple branches.
Was this helpful?
Thanks for your feedback!