The Wayback Machine - https://web.archive.org./web/20201028204416/https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/enabling-branch-restrictions

Enabling branch restrictions

You can enforce branch restrictions so that only certain users, teams, or apps can push to a protected branch in repositories owned by your organization.

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, 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. For more information, see "GitHub's products."

Did this doc help you?

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

Or, learn how to contribute.

Anyone with admin permissions to an organization-owned 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, 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. Optionally, select Include administrators. This enforces all configured restrictions for repository administrators.
    Include administrators checkbox
  7. Under "Protect matching branches", select Restrict who can push to matching branches.
    Branch restriction checkbox
  8. Search for and select the people, teams, or apps who will have permission to push to the protected branch.
    Branch restriction search
  9. Click Create.

Further reading

Did this doc help you?

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

Or, learn how to contribute.