Learning center

How do rulesets and branch protection rules combine?

All rulesets and the branch protection rule on a branch apply together, and the stricter version of any shared rule wins. A ruleset can add a requirement but never relax one, while only one branch protection rule applies to a branch. Migrate by converting each rule, running both until the ruleset matches, and deleting the old rule last.

What GitHub does when several rules target one branch#

GitHub's documentation describes two different models. For rulesets, "A ruleset does not have a priority. Instead, if multiple rulesets target the same branch or tag in a repository, the rules in each of these rulesets are aggregated. If the same rule is defined in different ways across the aggregated rulesets, the most restrictive version of the rule applies." The same page adds that rulesets "also layer with protection rules targeting the same branch or tag." About rule layering

The documentation's own example combines a ruleset that requires signed commits and three reviews with a branch protection rule that requires linear history and two reviews. The branch ends up requiring signed commits, linear history and three reviews.

Branch protection rules do not aggregate with each other. "Only a single branch protection rule can apply at a time," and when several match, "the rules that include a specific branch name have the highest priority." Among rules that use wildcards, older rules win: they "are applied in the order they were created." Managing a branch protection rule

Organization rulesets follow the ruleset model. Repository administrators can add their own rulesets beside an organization's, and "creating a new ruleset can make the rules targeting a branch or tag more restrictive, but never less restrictive." Creating rulesets for repositories in your organization

A required check that never reached main#

Suppose a fictional repository, acme/payments-api, has two classic branch protection rules. A rule named main requires one approving review. A newer rule with the pattern * requires the status check test on every branch whose name has no slash, since * does not match /. A maintainer adds test to the * rule and expects it to protect main as well.

It does not. The main rule names the branch exactly, so it takes priority, and the * rule's required check never applies to main. Nothing reports the gap. Pull requests into main merge with one approval whether or not test passed, while branches such as develop show the check as required. CI still runs and reports red, but nothing stops a merge on red.

If both rules were rulesets instead, the two would aggregate and main would require both the approval and the check. This is the main practical difference between the two models: with branch protection, adding a rule can silently change nothing, and with rulesets, adding a rule can only add requirements.

The aggregated model also has a cost. A ruleset cannot exempt one branch from a requirement another ruleset imposes. To create an exception, you narrow the stricter ruleset's targets with an exclude pattern or add a bypass actor, which is the job of the bypass list.

Migrating without a gap#

GitHub can convert a branch protection rule for you. In Settings, under Branches, each rule has Convert to ruleset. GitHub proposes one or more rulesets, shows a "New behavior" section listing what will change, and offers Delete branch protection rule once migration is done. Converting branch protections to rulesets Since October 2026 you can also convert every rule in a repository at once with Import branch protection rules on the Rulesets page. GitHub changelog, 20 October 2026

Leave the deletion box unchecked. The documentation says that if you keep the original rule, "it continues to protect matching branches," and that the new ruleset is Active, "so changes must satisfy both." For the overlap period, the branch is at least as strict as it was before, which is the property you want while migrating. Then:

  1. Read the "New behavior" section before creating anything. Look closely at who can bypass. By default, a branch protection rule does not apply to people with admin permissions (About protected branches), while a ruleset lets through only the roles, teams and apps on its bypass list.
  2. Create the ruleset as Active, keeping the original rule.
  3. Open the repository's /rules page, or read the merge box of an open pull request that the rules still block, and check that each requirement you expect appears. Anyone with read access can see active rulesets, unlike branch protection settings.
  4. When the Branches page reports the original rule as fully covered by rulesets and shows Delete in place of Convert to ruleset, delete it.

The converter changes the rule's model as well as its format. If your repository relied on the shadowing behavior above, where a specific rule overrode a wildcard rule, the ruleset version will apply both. Convert the specific rule and the wildcard rule, then expect the branch to carry the requirements of both.

What layering does not tell you#

Aggregation keeps the stricter setting, which is the right outcome for review policy, but it does not explain itself. A contributor who sees "3 approvals required" cannot tell from the number which ruleset asked for three. Name rulesets after the requirement and its owner, such as main: payments review (platform team), so the /rules page and the merge box answer that question.

Layering also does nothing for a requirement that no rule states. A required check that a workflow never reports keeps a pull request waiting whichever model holds it, and a skipped job still counts as a pass. The guides on required checks that wait for a status and on administrator bypass cover those failure modes.

Availability#

Rulesets are available in public repositories on GitHub Free and GitHub Free for organizations, and in public and private repositories on GitHub Pro, GitHub Team and GitHub Enterprise Cloud. A repository can have up to 75 rulesets. About rulesets Organization-level rulesets are available on GitHub Team and GitHub Enterprise plans; Team plans gained them in June 2025. GitHub changelog, 16 June 2025

The decision#

Write new requirements as rulesets. Convert existing branch protection rules when you next change them, or sooner if a repository has both a specific rule and a wildcard rule for the same branch, since that pair is where requirements go missing without any sign. Keep each original rule until its ruleset is visibly enforcing the same requirements, and treat any exception as a bypass actor or an exclude pattern, never as a weaker second ruleset.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading