In Bitbucket Cloud branch permissions, how does Write access differ from Merge access via pull requests when you restrict main?
answer
- push versus land
- one implies the other
- patterns and branch types
- overlapping rules both apply
- named lists combine
basics
~20 sIn a Bitbucket Cloud branch restriction, Write access names who may push commits straight to the branch; Merge access via pull requests names who may merge a pull request into it. Anyone given write access automatically gets merge access too.
solid answer
~40 sA **branch restriction** on `main`, on a pattern such as `release/*`, or on a branch type from the branching model narrows what repository writers may do on matching branches. **Write access** names who may push directly; **Merge access via pull requests** names who may land a pull request there, and everyone with write access gets that merge right automatically. To route every change through review, keep write access to a small group and grant merge access to the developers group. Watch overlaps: a `*` rule and a `main` rule both apply to `main`; when both name people, either list gets access, and a named list beats Everybody. Conditions such as two approvals are not permissions at all: they are **merge checks**, set in the same restriction.
go deeper
Recall the two fields: one is about pushing, the other about merging pull requests, and which one implies the other.
Explain how to express 'everything through review' with the two lists, how patterns and branch types match, and how overlapping rules combine.
Show you audit overlapping wildcard, type and name rules before trusting a restriction, and keep the write list as a small, reviewed break-glass group.
Weigh how much to restrict by rule versus by convention, and where a branching model with branch types scales better than one rule per branch.
## What a branch restriction is In Bitbucket Cloud, **branch restrictions** live in repository settings (and, with the same enforcement, in project settings). Each restriction matches branches by name, by pattern or by branch type, and carries two kinds of rule: **branch permissions**, which say *who* may change the branch, and **merge checks**, which say *under what conditions* a pull request may be merged. This question is about the first kind. Branch permissions work on top of repository permissions. Atlassian's own example gives everyone on the team **Write** on the repository and then narrows what they may do on `main` and `develop`. They exist to prevent accidents such as a new workspace member deleting the main branch, and Atlassian's example points out that on the restricted branches nobody can delete the branch or rewrite its history. ## The two permissions | Field | What it allows | Typical holders on `main` | |---|---|---| | **Write access** | Pushing commits directly to the branch, and merging pull requests into it | One or two maintainers, or a break-glass admin group | | **Merge access via pull requests** | Merging an approved pull request into the branch, but not pushing to it | The developers group | Two details carry most interviews: - **Write implies merge.** Anyone listed under write access automatically gets merge-via-pull-request access as well; you do not need to list them twice. - **Merge access does not imply write.** A user who only has merge access cannot push a commit to the branch; their only way in is a pull request. So "nobody pushes to main, everybody merges through review" is expressed as a short write list plus a broad merge list. ## Patterns, branch types and overlap A restriction can target: - a **branch name** such as `main`; - a **pattern** with a `*` at either end, such as `PROJECT-*`, which matches `PROJECT-1234`, `PROJECT-new` and `PROJECT-1.1`; - a **branch type** (feature, release, bugfix, hotfix, development, production) when the branching model is enabled, for example to restrict merges into every release branch. Branch types are worth the setup on a large project. The branching model maps each type to a prefix such as `release/` or `hotfix/`, and those prefixes can be changed for every type except development and production, which point at named branches instead. Only workspace admins can configure a project's branching model, so agree the prefixes before the restrictions that depend on them. Rules can overlap. If one restriction targets `main` and another targets `*`, **both apply** to `main`. Atlassian documents the result for the user lists: | `*` rule lists | `main` rule lists | Who has access on `main` | |---|---|---| | No users or groups | alice | Only alice | | Everybody | alice | Only alice | | alice | bob | Both alice and bob | | alice | Everybody | Only alice | The pattern is easy to state: **a named list beats Everybody, and two named lists combine**. The documented priority rules point the same way: user and group grants override anything else, DENY overrides ALLOW, and any branch-specific rule can override access that is not branch-specific. ## A setup that forces review on main 1. Open the repository's (or project's) branch restrictions and add one for `main`. 2. Under **Write access**, choose *Only specific people or groups have write access* and list a small maintainer group. 3. Under **Merge access via pull requests**, list the developers group. 4. In the same restriction, add merge checks for the conditions you care about, such as a minimum number of approvals. 5. Check existing `*` or branch-type rules, because their user lists combine with this one. ## What branch permissions do not do - They do not count approvals, builds or tasks; those are merge checks, and blocking a merge on them needs the Premium plan. - They are not where access is granted: who can read or write a repository at all is set by project and repository permissions. - They do not pick a merge strategy; that is a separate repository or project default. - They interact with branch clean-up: the *Delete source branch by default* option on merge does not apply to a branch whose deletion a branch permission prohibits. In short: branch permissions answer *who*, merge checks answer *when*, and a restriction usually needs both.
- In Bitbucket Cloud, a restriction on * lists alice for write access and one on main lists bob. Who may push to main?Both alice and bob. When two restrictions match the same branch and both name users or groups, the lists combine. Only when one of the rules says Everybody does the named list win and restrict access to the named users.
- How do you restrict merges into every release branch in Bitbucket Cloud without one restriction per branch?Either target a pattern such as `release/*`, or enable the branching model and restrict the release branch type, so any branch with the configured release prefix is covered as soon as it is created.
- Merge access via pull requests also lets those users push straight to the branch.
- Users with write access need a separate merge grant before they can merge pull requests.
- When a * rule and a main rule overlap, only the more specific main rule applies.
- Branch permissions alone can require two approvals before a pull request merges.
- A pattern such as PROJECT-* misses branches like PROJECT-new or PROJECT-1.1.