Skip to content
IonWarpTry for free
GitHub branch protection

GitHub branch protection rules: how to require pull request reviews

To require pull request reviews on GitHub, open the repository's Settings, click Branches and add a branch protection rule for main. Select Require a pull request before merging, then Require approvals, and set how many. Collaborators can then change main only through an approved pull request; admins are exempt until you select Do not allow bypassing the above settings.[1][2]

Example pull request#310

What lands on your pull request · Code Review

P1Retry charges the same order twice
billing/checkout.ts:42 · A timed-out response can charge the order twice
- await payments.charge(order);+ await payments.charge(order, {+   idempotencyKey: order.id,+ });
When payment succeeds but the response times out, the caller retries the same order. Both calls charge it. Pass the stable order ID as the payment idempotency key.

We build IonWarp, an AI reviewer for GitHub pull requests, so this guide also covers what most leave out: what an automated reviewer can and cannot satisfy. Our advice is to require one human approval, add the checks you trust and close the admin bypass. A required check can hold a merge; only a person can approve one.

How to require reviews, step by step

  • Open Branches in Settings

    On the repository's main page, click Settings, then Branches in the sidebar, then Add classic branch protection rule. You need admin access to the repository, or a custom role with the edit repository rules permission.[1][2]

  • Name the branch

    Type main under Branch name pattern, or a pattern such as *release* to protect every branch with that word in its name. The branch does not have to exist yet.[1][2]

  • Require the pull request and the approval

    Select Require a pull request before merging, then Require approvals, and choose the number. Select Dismiss stale pull request approvals when new commits are pushed, so a commit added after the review does not ride on the old approval. If a CODEOWNERS file names who owns each path, select Require review from Code Owners too; the CODEOWNERS tester shows who GitHub would ask.[1]

  • Require the checks

    Select Require status checks to pass before merging and search for each check by name. Pick a check that has already run on a pull request: when you set an expected source, GitHub offers an app that has recently set that check.[1][2]

  • Close the admin bypass and save

    By default a rule does not apply to people with admin permissions. Select Do not allow bypassing the above settings, then click Create. Force pushes and branch deletion are already blocked by the rule's defaults.[1][2]

  • Add IonWarp as a required check

    Sign in with GitHub and install the IonWarp GitHub App on the organization or user, choosing the repositories. It gives IonWarp read-only code access and writes pull request comments and checks. Starter is free for 3 people with 15,000 credits to start; Pro is $49/mo for 5 seats. Open a pull request, let the review finish, then search for IonWarp / Review under the required checks.

    Code ReviewOn Starter, Pro and Max

Where a rule goes wrong, and what to do instead

  1. A private repository on GitHub Free

    Protected branches and rulesets are available on public repositories with GitHub Free, and on public and private repositories with GitHub Pro, Team and Enterprise. A private repository on GitHub Free gets neither.[2][3]

  2. One developer and a required approval

    An author cannot approve their own pull request,[4] so on a one-person repository a required approval can only be met through the admin bypass. Select Require a pull request before merging and leave Require approvals off: the two are separate options, so changes still go through a pull request and no second person is needed.[5]

  3. A required check that never reports

    A workflow skipped by path filtering or branch filtering leaves its check pending, and the pull request waits on Waiting for status to be reported. Do not require a workflow a filter can skip, and keep job names unique across workflows, because a repeated name can block merges too.[6][2]

  4. A classic rule or a ruleset

    GitHub calls the rule in these steps a classic rule, and rulesets set the same requirements under Settings, Rules, Rulesets, New branch ruleset. Several rulesets can apply to one branch and anyone with read access can see them; only one classic rule applies to a branch. Where both exist, every rule applies and the strictest version wins.[3][7]

  5. A person still approves

    IonWarp's review is one comment on the pull request, with the file, the line and a suggested fix, plus the check. It never submits an approval, so it cannot count toward Require approvals. The reading that does count is a person's: how to review a pull request walks through it.

What GitHub does with IonWarp's check when you require it

IonWarp holds a merge only if you mark IonWarp / Review as required in GitHub; there is no separate IonWarp switch. Without a rule, every row below can merge. The P0, P1, P2 and did-not-run results are defaults you can change in IonWarp's Status Checks settings.

CriterionIonWarpWith the check required on GitHub
A P0 finding is openAction requiredNot a passing status, so the merge waits until a push fixes the finding or someone replies wontfix with a reason.[6]
Only P1 findings are openNeutralCounts as passing, so the pull request can merge.[6]
A clean review, or only P2 findingsSuccessPassing, so the pull request can merge.[6]
A draft, a release pull request, or no reviewable diffSkippedCounts as passing, so it never holds a merge.[6]
The review could not run (it failed, credits ran out, or the project is paused)Action required, or set Review did not run to NeutralThe merge waits. Comment @ionwarp review now to retry, or choose Neutral if a missed review should not hold a release.[6]
Pricing

Simple pricing for your whole team.

One workspace price with seats included. Credits pool across your team. Unlimited repos on every plan.

Starter

$0 /mo

Try AI PR review.

  • 2 reviewers
    • Code Review
    • Security Review
  • 3 seats included
  • 15,000 credits to start, then 5,000/mo
  • About 70 reviews to start, then about 25 a month
  • Unlimited repos
Get Started

Max

$149 /mo

Scale AI PR review.

  • +9 reviewers
    • UX Review
    • API Performance
    • Analytics Review
    • SEO Review
    • Changelog
    • CI/CD Performance
    • Plan Review
    • Repeat-Failure Learnings
    • SOC 2 Review
  • 10 seats included
  • +75,000 credits/mo
  • About 360 reviews a month
  • +$29/mo per added seat
  • Unlimited repos
  • Priority support
Choose Max
Enterprise

Custom reviewers + credits · GitHub Enterprise · SSO/SAML + audit logs · Custom security review + SLA

Contact us
FAQ

Frequently asked questions

How do I require pull request reviews on GitHub?

In the repository, open Settings, then Branches, and add a classic branch protection rule for your main branch. Select Require a pull request before merging, then Require approvals, choose the number of approvals, and click Create.

How do I protect the main branch on GitHub?

Add a branch protection rule with the pattern main. The rule blocks force pushes and deletion by default, Require a pull request before merging stops direct pushes, and Do not allow bypassing the above settings applies the rule to admins.

Why can't I use branch protection on a private repository?

On GitHub Free, protected branches and rulesets are available on public repositories only. Private repositories need GitHub Pro, Team or Enterprise.

Can I approve my own pull request on GitHub?

No. A pull request's author cannot approve it, so a required approval needs a second person with write access to the repository.

Can an AI reviewer satisfy a required review on GitHub?

IonWarp cannot: its review is a comment and a check, never an approval, so a required approval still needs a person. You can require its check, IonWarp / Review, which by default holds the merge while a P0 finding is open.

What is the difference between a ruleset and a branch protection rule?

Both can require reviews and checks. Several rulesets can apply to one branch and anyone with read access can see them, while only one classic rule applies to a branch. Where both exist, every rule applies and the strictest wins.

Sources

  1. Managing a branch protection ruleGitHub Docs · read
  2. About protected branchesGitHub Docs · read
  3. About rulesetsGitHub Docs · read
  4. Approving a pull request with required reviewsGitHub Docs · read
  5. Require pull requests without requiring reviewsThe GitHub Blog · read
  6. Troubleshooting required status checksGitHub Docs · read
  7. Creating rulesets for a repositoryGitHub Docs · read