Safeguard
Security Guides•

How do Bitbucket Cloud branch permissions work with patterns and overlap?

Bitbucket Cloud branch permissions limit write and merge access by name or pattern, and overlapping rules all apply. Set pull request only merges on main.

Safeguard Security Team
4 min read

Bitbucket Cloud branch permissions let you limit who can write to a branch and who can merge to it through pull requests, matched by branch name or pattern. When several rules match one branch, they all apply. A typical production setup allows merges only through pull requests and grants write access to almost nobody.

The two permission types

Atlassian's documentation describes two settings on the Branch permissions tab.

SettingWhat you chooseEffect
Write accessOnly specific people or groups have write accessLimits who can push directly
Merge access via pull requestsOnly specific people or groups have merge accessLimits who can merge a pull request

The page notes that deleting a repository or rewriting its history requires write or admin permissions, and its example leaves no one able to delete or rewrite history on the protected branches. It does not name a separate switch for those two actions, so verify the behavior on a test repository before you rely on it.

Patterns

You can target a branch by name or by pattern in the By name or pattern field. Add a wildcard at either end, for example PROJECT-* to match PROJECT-1234. If your repository uses the branching model, you can also target branch types, such as release branches.

Overlap: everything that matches applies

If several restrictions match the same branch, all of them apply. A rule on * and a rule on main both govern main. That has two practical effects.

  1. A broad rule can silently tighten a branch. A team may wonder why they cannot push to a feature branch, and the answer is a wildcard rule written months ago.
  2. You cannot loosen a branch by adding a more specific rule, because the broader rule still applies. To loosen, edit or narrow the broad rule.

A configuration to start from

  1. Open More actions, then Settings, then Branch restrictions under Workflow.
  2. Add a restriction on your default branch.
  3. Set Write access to a very small group, or nobody if your process allows.
  4. Set Merge access via pull requests to the group that owns releases.
  5. Add a restriction for your release branches by pattern or branch type with the same rules.
  6. Add merge checks. See merge checks.
  7. Test with a throwaway account that holds only write access to the repository.

Reviewing the setup every quarter

Print the list of restrictions and ask, for each, who is in the groups and whether anyone left. Also look for gaps: a new long lived branch such as a maintenance release that no pattern covers. Admins matter too, as the page ties write and admin permission to history rewriting. Keep the admin list short.

Try it yourself

The gate demo shows a protected path where changes must pass a check before merging. Click through it and think about which of your branches have no such gate.

Click through it at your own pace, or open it full screen.

Quick check

If two rules match a branch, which wins?

Neither. Atlassian says all matching restrictions apply, so the effective rule is the combination.

How do I match all branches starting with release?

Use a pattern with a wildcard at the end, such as release*, in the By name or pattern field.

Safeguard policies and gates can add dependency checks to pull requests on branches you have restricted. A free scan is at gold.safeguard.sh/scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.