About branch protection rules
Puedes crear una regla de protección de rama en un repositorio para la rama específica, todas las ramas, o cualquier rama que coincida con un patrón de nombre que especifiques con la sintaxis fnmatch
. Por ejemplo, para proteger cualquier rama que contenga la palabra release
, puedes crear una regla de rama de *release*
.
You can create a rule for all current and future branches in your repository with the wildcard syntax *
. Because GitHub 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 the available branch protection settings, see "About protected branches."
Creating a branch protection rule
When you create a branch rule, the branch you specify doesn't have to exist yet in the repository.
-
En tu instancia de GitHub Enterprise Server, visita la página principal del repositorio.
-
Debajo de tu nombre de repositorio, da clic en Configuración.
-
En el menú izquierdo, da clic en Ramas.
-
Junto a "Reglas de protección de rama", da clic en Agregar regla.
-
Debajo del "Patrón del nombre de la rama", teclea el nombre de la rama o el patrón que quieras proteger.
-
Optionally, enable required pull request reviews.
-
Under "Protect matching branches", select Require pull request reviews before merging.
-
Click the Required approving reviews drop-down menu, then select the number of approving reviews you would like to require on the branch.
-
Optionally, to dismiss a pull request approval review when a code-modifying commit is pushed to the branch, select Dismiss stale pull request approvals when new commits are pushed.
-
Optionally, to require review from a code owner when the pull request affects code that has a designated owner, select Require review from Code Owners. For more information, see "About code owners."
-
Optionally, if the repository is part of an organization, select Restrict who can dismiss pull request reviews. Then, search for and select the actors who are allowed to dismiss pull request reviews. For more information, see "Dismissing a pull request review."
-
-
Optionally, enable required status checks. For more information, see "About status checks."
- Select Require status checks to pass before merging.
- Optionally, to ensure that pull requests are tested with the latest code on the protected branch, select Require branches to be up to date before merging.
- Search for status checks, selecting the checks you want to require.
-
Optionally, select Require signed commits.
-
Optionally, select Require linear history.
-
Optionally, select Apply the rules above to administrators.
-
Optionally, enable branch restrictions.
- Select Restrict who can push to matching branches.
- Search for and select the people, teams, or apps who will have permission to push to the protected branch or create a matching branch.
-
Optionally, under "Rules applied to everyone including administrators", select Allow force pushes.
For more information about force pushes, see "Allow force pushes."
-
Optionally, select Allow deletions.
-
Click Create.
Editing a branch protection rule
-
En tu instancia de GitHub Enterprise Server, visita la página principal del repositorio.
-
Debajo de tu nombre de repositorio, da clic en Configuración.
-
En el menú izquierdo, da clic en Ramas.
-
To the right of the branch protection rule you want to edit, click Edit.
-
Make your desired changes to the branch protection rule.
-
Click Save changes.
Deleting a branch protection rule
-
En tu instancia de GitHub Enterprise Server, visita la página principal del repositorio.
-
Debajo de tu nombre de repositorio, da clic en Configuración.
-
En el menú izquierdo, da clic en Ramas.
-
To the right of the branch protection rule you want to delete, click Delete.