# Stash Latest (2.12) : Using branch permissions

Created and last modified by pwatson on Mar 25, 2014

Branch permissions allow you to control who can commit to specific branches in a repository. Branch permissions provide another level of security within Stash (along with user authentication and project, repository and global permissions) that provides a way 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.
- are based on explicit branch names, or you can use advanced branch permissions to match multiple branches (or tags) using pattern matching.

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.

Note that if no branch permissions are defined then anyone with commit access to the repository can push to any branch.

On this page:

Related pages:

- Using pull requests in Stash
- Controlling access to code
- Global permissions

## Setting branch permissions

Branch permissions in Stash are set on a per-repository basis. Makes sense – branch permissions control access to repository branches, right?

You'll need either project admin, admin or sys-admin permissions to set branch permissions.

So, to set branch permissions:

1. Go to a repository in a project.
2. Choose Settings > Branch (under 'Permissions').
3. Click Add permission.
4. On the Branch tab, choose the branch for which you want to control access.
5. Add (or remove) users or groups that you want to have (or not have) commit access to the branch.
6. Click Create to finish.

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

## Advanced branch permissions

Advanced branch permissions specify a pattern that is matched against branches and tags being pushed to Stash; this allows you to restrict any pushes to branches that match the pattern.

Advanced branch permission also apply to attempts to create new branches; if a push to Stash attempts to create a new branch that matches a pattern, the user must be authorised for the operation to proceed.

To set advanced branch permissions, choose Settings > Branch, and click Add permission, as described above.

On the Advanced tab, enter a glob pattern to match the names of multiple branches for which you want to control access.

## Attachments:

STASH20_branch_perm.png (image/png)
STASH20_branch_perm_adv.png (image/png)
STASH20_branchpermissions.png (image/png)
STASH20_branchpermissions.png (image/png)
STASH20_branch_perm_adv.png (image/png)
image2012-11-28 10:54:49.png (image/png)
image2012-11-28 10:54:49.png (image/png)
STASH20_branch_perm_adv.png (image/png)
STASH20_branchpermissions.png (image/png)
STASH20_branch_perm.png (image/png)
STASH24_choose_branch.png (image/png)
STASH24_choose_branch.png (image/png)
STASH20_branch_perm.png (image/png)
STASH20_branchpermissions.png (image/png)
STASH20_branch_perm_adv.png (image/png)
image2012-11-28 10:54:49.png (image/png)