October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

GitHub Branch Protection: Require Pull Requests and Code Reviews

Protect a GitHub branch by requiring pull requests and approvals, then choose how new commits affect existing reviews and whether code owners must approve.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To require code review before changes reach a GitHub branch, protect that branch, require pull requests, and set a minimum approval count. In a repository, open Settings → Branches, add or edit a branch protection rule for the target branch or pattern, configure the review requirements, and save. A pull-request requirement and an approval requirement are separate controls, so enable both if every change must receive approval.

Set up a branch protection rule

  1. Choose the branch. In the repository, go to Settings → Branches and add or edit a rule. Set the branch name or pattern to match the branch where changes need review, such as the repository’s main development branch. A rule only applies to branches it matches.
  2. Require pull requests. Enable the option requiring a pull request before merging. This prevents changes from being merged directly under the rule, but does not by itself require anyone to approve the pull request.
  3. Set the approval minimum. Configure the required number of approving reviews. GitHub says eligible approvals come from people with write permission. Choose a count that fits the team’s size and the risk of changes; there is no universally suitable number.
  4. Choose what happens after new changes. Decide whether earlier approvals should remain valid or whether changes should trigger additional review. The two relevant options are described below.
  5. Save and check the rule. Save the settings, then use a pull request targeting the protected branch to verify that the rule matches the intended branch and that GitHub enforces the expected merge requirements. See GitHub’s branch protection rule guide.

Choose how approvals respond to new commits

New commits can alter what reviewers approved. GitHub offers two approaches for handling that change; choose according to how much re-review your workflow needs.

As an Amazon Associate I earn from qualifying purchases.

Dismiss stale approvals

Enable dismissal of stale pull request approvals when changes to the diff should invalidate earlier approval. A reviewer must then approve the updated changes. GitHub also documents cases where a changed merge base can make an approval stale. This approach is useful when the team wants approval to apply only to the code currently proposed, but it can mean repeating reviews as a pull request changes.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Require approval of the most recent reviewable push

Alternatively, require approval of the most recent reviewable push. The person who made that push cannot provide the qualifying approval; it must come from someone else. This focuses the requirement on review of the latest push rather than dismissing every earlier approval. See GitHub’s documentation on available rules for details.

GitHub warns that either stale-approval dismissal or latest-push approval affects direct manual merge-commit pushes to a protected branch: the push fails unless the merge exactly matches GitHub’s generated merge.

Require review from code owners

For path-specific review, add a CODEOWNERS file and enable the code owner review requirement in the branch protection rule. GitHub looks for this file in .github/, the repository root, or docs/. Make sure its patterns cover the files that need ownership. If several owners match a file, an approval from any one of them satisfies that code owner requirement.

Protect the policy itself: GitHub recommends assigning an owner to the CODEOWNERS file or the .github/ directory. Otherwise, changes to ownership rules may not receive the intended oversight. More detail is in GitHub’s guide to code owners.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Branch protection rules or rulesets?

Classic branch protection rules are managed in Settings → Branches. Rulesets are an alternative way to apply repository policies. GitHub describes rulesets as easier to discover without admin access and able to apply multiple rulesets at once. The rules and behavior available differ, so teams using rulesets should consult GitHub’s current ruleset documentation rather than assuming every branch-protection option behaves identically.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Review is only one merge gate

Required approvals do not automatically enable other protections. Depending on the repository’s needs, configure separate requirements for status checks, conversation resolution, signed commits, linear history, merge queues, deployments, push restrictions, or bypass permissions. GitHub outlines these controls in its overview of protected branches.

GitHub documents branch protection for public repositories on Free, and for public and private repositories on Pro, Team, Enterprise Cloud, and Enterprise Server. Plan availability can change; check the current documentation for the account and GitHub product you use.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.