Article version: Enterprise Server 2.15

This version of GitHub Enterprise will be discontinued on This version of GitHub Enterprise was discontinued on 2019-10-16. No patch releases will be made, even for critical security issues. For better performance, improved security, and new features, upgrade to the latest version of GitHub Enterprise. For help with the upgrade, contact GitHub Enterprise support.

Enabling branch restrictions

You can enforce branch restrictions so that only certain users or teams are able to push to a protected branch.

Protected branches are available in public repositories with GitHub Free, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. The ability to restrict branches is a type of branch protection that's available for public and private repositories owned by organizations in GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server.

Anyone with admin permissions to a repository can enable branch restrictions.

You can automatically enforce protected branch settings for some or all branches in your repository. For more information, see "Configuring protected branches."

  1. On GitHub Enterprise, navigate to the main page of the repository.

  2. Under your repository name, click Settings.

    Repository settings button

  3. In the left menu, click Branches.

    Repository options sub-menu

  4. Next to "Branch protection rules", click Add rule.

    Add branch protection rule button

  5. Under "Branch name pattern", type the branch name or pattern you want to protect.

    Branch rule field

  6. Under "Rule settings", select Restrict who can push to matching branches.

    Branch restriction checkbox

  7. Search for and select the users or teams who will have permission to push to the protected branch.

    Branch restriction search

  8. Click Save changes.

Further reading

Ask a human

Can't find what you're looking for?

Contact us