Stash is now known as Bitbucket Server.
See the

Unknown macro: {spacejump}

of this page, or visit the Bitbucket Server documentation home page.

Branch permissions allow you to control the actions users can perform on a single branch, branch type, or branch pattern within a repository. Branch permissions provide another level of security within Stash, along with user authentication and projectrepository and global permissions, that together allow you to control, or enforce, your own workflow or process.

Branch permissions:

  • are based on users or groups.
  • are actually restrictions, which are checked after project and repository level permissions.
  • are used to limit branch access to specific people who must still have write access to the project or repository.
  • prevent unauthorised users pushing to or deleting the branch.
  • can be based on explicit branch names, branch pattern, or branching model.

For example, if two developers Xavier and Yves have write access to repository R, but only Xavier has branch permissions on branch B, then Yves won't be able to push to B.

If a user does not have commit access to the branch, an error message will be shown on the Git command line when they try to push a change to the branch. If no branch permissions are defined then anyone with commit access to the repository can push to any branch. 

Adding branch permissions

Branch permissions in Stash control access to repository branches. You need either project admin, admin or sys-admin permissions to set or modify branch permissions.

To add branch permissions:

  1. Go to a repository in a project.
  2. Choose Settings > Branch permissions.
  3. Click Add permission.
  4. In the Branches field, select either Branch name, Branch pattern, or Branching model.
    1. Branch name - select an existing branch by name.
    2. Branch pattern - specify a branch using branch pattern syntax for matching branch names. See Branch permission patterns for more information about this syntax.
    3. Branching model - select the branch type to restrict access to. Read more about branching models.  
  5. Add (or remove) users or groups that you want to have (or not have) commit access to the branch. Limiting write access for a branch enforces the branch permissions, and also
    1. restricts pushes to branches.
    2. restricts creating new branches.
  6. Select the type of actions you want to prevent.
    1. Rewriting history - prevents history rewrites on the specified branch(es) - for example by a force push or rebase.
    2. Changes without a pull request - prevents pushing changes directly to a branch; changes are allowed only with a pull request.
    3. Branch deletion - prevents branch and tag deletion.
  7. Click Create to finish.

You can always change the permissions for a branch later, if necessary.

  • No labels