Article version: Enterprise Server 2.17
About protected branches
Protected branches ensure that collaborators on your repository cannot make irrevocable changes to branches. Enabling protected branches also allows you to enable other optional checks and requirements, like required status checks and required reviews.
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.
By default, any pull request can be merged at any time, unless the head branch is in conflict with the base branch. You can choose to enforce restrictions on how a pull request is merged into your repository.
Repository owners and people with admin permissions for a repository can enforce certain workflows or requirements, before a collaborator can merge a branch in your repository by creating protected branch rules.
You can create a branch rule in a repository for a specific branch, all branches, or any branch that matches a naming pattern specified with the fnmatch syntax. For example, to require any branch containing the word
release to have at least two pull request reviews before merging, you can create a branch rule for
*release*. For more information, see "Configuring protected branches."
If a repository has multiple protected branch rules that affect the same branches, the rules that include a specific branch name have the highest priority. If there is more than one protected branch rule that references the same specific branch name, then the branch rule created first will have higher priority.
Protected branch rules that mention a special character, such as
], are applied in the order they were created, so older rules with these characters have a higher priority.
When you create a branch protection rule in a repository, collaborators cannot force push to the protected branch or delete the branch. You can enable other branch protection settings. For information, see "Defining the mergeability of pull requests."