

Note: If you select Dismiss stale pull request approvals when new commits are pushed and/or Require approval of the most recent reviewable push, manually creating the merge commit for a pull request and pushing it directly to a protected branch will fail, unless the contents of the merge exactly match the merge generated by GitHub for the pull request. 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.įor more information about each of the available branch protection settings, see " About protected branches." 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. 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. 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. You can also extend the qa string with qa**/**/* to make the rule more inclusive.įor more information about syntax options, see the fnmatch documentation. You can include any number of slashes after qa with qa/**/*, which would match, for example, qa/foo/bar/foobar/hello-world. For example, qa/* will match all branches beginning with qa/ and containing a single slash, but will not match qa/foo/bar. Because GitHub uses the File::FNM_PATHNAME flag for the File.fnmatch syntax, the * wildcard does not match directory separators ( /).

You can create a rule for all current and future branches in your repository with the wildcard syntax *.

For example, to protect any branches containing the word release, you can create a branch rule for *release*. You can create a branch protection rule in a repository for a specific branch, all branches, or any branch that matches a name pattern you specify with fnmatch syntax.
