Lesstep
Bitbucket Cloud · branch restrictions · Checked November 10, 2026

Bitbucket Cloud branch restrictions

Branch restrictions are in the repository's Settings → Branch restrictions, under Workflow. Each one applies to a branch name or a pattern such as release/* and says who may write to it or merge into it through pull requests, whether its history may be rewritten or the branch deleted, and which merge checks its pull requests need (Use branch permissions). Below are the problems Atlassian's knowledge base answers about them.

A group or a person is not in the list

To see the merge checks of each pull request before you merge: Pull Request Inbox for Bitbucket, a plugin for JetBrains IDEs, lists the pull requests that wait for your review and shows which checks pass and which block the merge.

"Internal server error" when you save one

In a repository with many branches, 500 or more, saving a branch restriction can run out of time and answer with a 500 error. The knowledge base's fix is fewer branches; it suggests keeping a repository under about 200 (Issue while updating branch restrictions). Merged branches are the easy ones to delete.

New branches: use a pattern

A new branch does not take over the restrictions of the branch it was made from. It gets the restrictions whose pattern its name matches, so a restriction on release/* covers every release branch from the moment it exists. Otherwise, create the restriction through the API once the branch is there, for example from a pipeline step that runs on every branch (Inherit branch restrictions for newly created branch from existing branch).

In a pattern, * matches zero or more characters and every other character matches itself: foo* matches foo and foobar but not barfoo, and * matches every branch. A restriction can also follow the repository's branching model instead, by branch type: production, development, bugfix, release, feature or hotfix (Branch restrictions in the REST API reference).

Allow only some branch names

To let people create only some branches, take write access and merging through pull requests away on *, then give them back on the names you allow. The knowledge base's example allows main and branches that start with test (Restrict Creation of Branches to Certain Patterns):

PatternWrite access and merging through pull requests
*No one
mainThe people or groups who may push to it
test*The people or groups who may create test branches

A branch that matches both a name and * gets both restrictions. The same article shows what that enforces:

On *On mainWho has access to main
No users or groupsUser AOnly user A
EverybodyUser AOnly user A
User AUser BUser A and user B
User ANo users or groupsOnly user A
User AEverybodyOnly user A

Through the API

POST /2.0/repositories/{workspace}/{repository}/branch-restrictions creates one, with an API token that has admin:repository:bitbucket. Each has a kind and a pattern. Only push and restrict_merges take users (by UUID, from the workspace members list) and groups: they are the ones let through, and an empty list stops everybody. To add people to an existing one, use PUT on its ID (the REST API reference; How to create/edit branch restrictions in Bitbucket Cloud repositories via API). For example, no direct pushes to release branches:

curl --request POST --user 'you@example.com:{api_token}' \
  --header 'Content-Type: application/json' \
  --data '{"pattern": "release/*", "kind": "push", "users": [], "groups": []}' \
  https://api.bitbucket.org/2.0/repositories/{workspace}/{repository}/branch-restrictions
On the settings pagekind
Write accesspush
Merge via pull requestsrestrict_merges
Minimum number of approvalsrequire_approvals_to_merge, with value
Minimum number of approvals from default reviewersrequire_default_reviewer_approvals_to_merge, with value
Minimum number of successful builds for the last commit with no failed builds and no in progress buildsrequire_passing_builds_to_merge, with value
Maximum number of commits behind destination branchrequire_commits_behind, with value
No unresolved pull request tasksrequire_tasks_to_be_completed
No changes are requestedrequire_no_changes_requested
Reset approvals when the source branch is modifiedreset_pullrequest_approvals_on_change
Keep approvals if there is no change to the diff in the pull requestsmart_reset_pullrequest_approvals
Reset requested changes when the source branch is modifiedreset_pullrequest_changes_requested_on_change
Prevent a merge with unresolved merge checksenforce_merge_checks
Allow automatic merge when builds passallow_auto_merge_when_builds_pass

Two more kinds, force and delete, go with Allow rewriting branch history and Allow deleting this branch.

Bitbucket pull requests in IntelliJ IDEA

Pull Request Inbox for Bitbucket, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, lists the pull requests that wait for your review in an IDE tool window, with their diffs and discussions, and shows next to each which merge checks pass and which block the merge. The review inbox, diffs, discussions and merge checks are free; approving, commenting and merging are Pro, with a 30-day trial. It also works with Bitbucket Data Center (beta).

Get it on JetBrains Marketplace

Bitbucket and Atlassian are trademarks of Atlassian; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by Atlassian or JetBrains.

More: Bitbucket merge checks · "pre-receive hook declined" · Restore a deleted branch · Changes missing from a branch · 日本語