Branch permission patterns

Using branch permissions

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

Bitbucket Data Center and Server supports a powerful type of pattern syntax for matching branch names (similar to pattern matching in Apache Ant). You can use branch permission patterns when adding branch permissions at the project or repository level to apply a branch permission to multiple branches.

These expressions can use the following wild cards:

?Matches one character (any character except path separators)
*Matches zero or more characters (not including path separators)
**Matches zero or more path segments.

Pattern used in branch permissions match against all refs pushed to Bitbucket (i.e. branches and tags).

In Git, branch and tag names can be nested in a namespace by using directory syntax within your branch names, e.g. stable/1.1. The '**' wild card selector enables you to match arbitrary directories.

  • A pattern can contain any number of wild cards.
  • If the pattern ends with / then ** is automatically appended - e.g. foo/ will match any branches or tags containing a foo path segment
  • Patterns only need to match a suffix of the fully qualified branch or tag name. Fully qualified branch names look like refs/heads/master, while fully qualified tags look like refs/tags/1.1.

Also see the Ant documentation.

Examples

*Matches everything
PROJECT-*Matches any branch or tag named PROJECT-*, even in a name space.

e.g. refs/heads/PROJECT-1234, refs/heads/stable/PROJECT-new or refs/tags/PROJECT-1.1

?.?Matches any branch or tag of 2 characters separated by a '.'.

e.g. refs/heads/1.1, refs/heads/stable/2.X or refs/tags/3.1

tags/ or

tags/**

Matches all tags and any branches with 'tags' as a namespace.

e.g. refs/heads/stable/tags/some_branch, refs/tags/project-1.1.0

heads/**/masterMatches all branches called master.

e.g. refs/heads/master, refs/heads/stable/master

Last modified on Apr 26, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.