Are you sure you want to delete this access key?
title | intro | product | redirect_from | versions | permissions |
---|---|---|---|---|---|
Managing a branch protection rule | You can create a branch protection rule to enforce certain workflows for one or more branches, such as requiring an approving review or passing status checks for all pull requests merged into the protected branch. | {% data reusables.gated-features.protected-branches %} | [/articles/configuring-protected-branches /enterprise/admin/developer-workflow/configuring-protected-branches-and-required-status-checks /articles/enabling-required-status-checks /github/administering-a-repository/enabling-required-status-checks /articles/enabling-branch-restrictions /github/administering-a-repository/enabling-branch-restrictions /articles/enabling-required-reviews-for-pull-requests /github/administering-a-repository/enabling-required-reviews-for-pull-requests /articles/enabling-required-commit-signing /github/administering-a-repository/enabling-required-commit-signing /github/administering-a-repository/requiring-a-linear-commit-history /github/administering-a-repository/enabling-force-pushes-to-a-protected-branch /github/administering-a-repository/enabling-deletion-of-a-protected-branch] | [{free-pro-team *} {enterprise-server *} {github-ae *}] | People with admin permissions to a repository can manage branch protection rules. |
{% data reusables.repositories.branch-rules-example %}
You can create a rule for all current and future branches in your repository with the wildcard syntax *
. Because {% data variables.product.company_short %} uses the File::FNM_PATHNAME
flag for the File.fnmatch
syntax, the wildcard does not match directory separators (/
). For example, qa/*
will match all branches beginning with qa/
and containing a single slash. You can include multiple slashes with qa/**/*
, and you can extend the qa
string with qa**/**/*
to make the rule more inclusive. For more information about syntax options for branch rules, see the fnmatch documentation.
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 *
, ?
, or ]
, are applied in the order they were created, so older rules with these characters have a higher priority.
To create an exception to an existing branch rule, you can create a new branch protection rule that is higher priority, such as a branch rule for a specific branch name.
For more information about each of each of the available branch protection settings, see "About protected branches."
When you create a branch rule, the branch you specify doesn't have to exist yet in the repository.
{% data reusables.repositories.navigate-to-repo %} {% data reusables.repositories.sidebar-settings %} {% data reusables.repositories.repository-branches %} {% data reusables.repositories.add-branch-protection-rules %}
{% data reusables.repositories.navigate-to-repo %} {% data reusables.repositories.sidebar-settings %} {% data reusables.repositories.repository-branches %}
{% data reusables.repositories.navigate-to-repo %} {% data reusables.repositories.sidebar-settings %} {% data reusables.repositories.repository-branches %}
Press p or to see the previous file or, n or to see the next file
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?
Are you sure you want to delete this access key?