Learning center

Should pull requests be up to date with the base before merging?

Require branches to be up to date when two pull requests that pass on their own can break the base branch together. Strict checks suit a branch with few merges a day, where authors rarely have to catch up twice; on a busy branch, a merge queue runs the same test without asking every author to update and re-run.

What strict checks add#

GitHub calls the two modes "strict" and "loose." Strict means the Require branches to be up to date before merging checkbox is checked and "The branch must be up to date with the base branch before merging." Loose means it is not, and GitHub's own note on that mode is the reason to consider strict: "Status checks may fail after you merge your branch if there are incompatible changes with the base branch." About protected branches Rulesets have the same choice, exposed in the REST API as strict_required_status_checks_policy, "Whether pull requests targeting a matching branch must be tested with the latest code" (repository rulesets API).

Loose checks are not as stale as they sound. A pull_request workflow tests the merge branch: "Your CI tests run against the merged result, not just the head branch alone." Events that trigger workflows But that merged result is the base branch as it was when the run started. If another pull request merges afterwards, the green check describes a combination that no longer exists, and the next merge creates one nobody tested.

A fictional pair of green pull requests#

Suppose acme/billing has a module with a function charge(order). Two pull requests are open against main.

Pull request A renames charge to capture and updates every caller in the repository. Its tests pass against main as it was that morning.

Pull request B adds a refund flow in a new file that calls charge(order). Its tests pass against the same main, where charge still exists.

The two pull requests touch different files, so Git reports no conflict between them. A reviewer of B has no reason to look at A. A merges first. Under loose checks, B's existing green run still satisfies the rule, B merges, and main no longer compiles: the new file calls a function that A removed. The first sign is the next push to main, or a deploy.

Under strict checks, B cannot merge after A lands until B is brought up to date with main. Updating starts a new run on a merge result that contains A's rename, the build fails on B's call to charge, and B's author fixes it before merging. That is the defect strict checks exist to catch: a semantic conflict between two changes that were each correct on their own base.

What strict checks do not catch#

They catch only what your checks test. If the conflict is a behavior difference that no test covers, the updated branch is green and the break still merges. They also say nothing about environments: both pull requests can pass together and still fail against production configuration that CI never sees.

Strict checks also judge one pull request at a time. The rule requires the branch to be current when it merges, so whichever pull request merges next makes the others stale and sends them back to update. Correctness holds, but the work multiplies, which is the cost below.

What it costs#

GitHub's description of strict mode states the cost directly: "More builds may be required, as you'll need to bring the head branch up to date after other collaborators update the target branch." On a branch that merges a few pull requests a day, that means an occasional Update branch click and a re-run. On a branch that merges dozens, it turns into a race: every merge makes every other open pull request stale, each author updates and waits for CI, and only the first to finish wins. The rest update again.

There is a second cost if you also dismiss stale approvals. GitHub's description of that setting gives clicking Update branch as an example of a diff change that dismisses the approving review (about protected branches). Combine the two settings on a busy branch and catching up can also mean waiting for a re-review of a change you did not make. Whether that trade is worth it is covered in dismissing stale approvals.

When a merge queue is the better tool#

GitHub positions the merge queue as the answer to that race. It "provides the same benefits as the Require branches to be up to date before merging branch protection, but does not require a pull request author to update their pull request branch and wait for status checks to finish before trying to merge." The queue tests each pull request "when applied to the latest version of the target branch and any pull requests already in the queue," and GitHub notes it is "particularly useful on branches that have a relatively high number of pull requests merging each day from many different users." Managing a merge queue

Availability decides for some teams: "Pull request merge queues are available in any public repository owned by an organization, or in private repositories owned by organizations using GitHub Enterprise Cloud." Managing a branch protection rule A private repository on another plan has strict checks as its only built-in option. A queue also needs your workflows to run on merge_group, which has its own failure mode (merge queue and required checks).

Configure strict checks#

In a ruleset, set the flag inside the required status checks rule:

{
  "type": "required_status_checks",
  "parameters": {
    "strict_required_status_checks_policy": true,
    "required_status_checks": [
      { "context": "ci-gate" }
    ]
  }
}

The REST reference adds that the setting "will not take effect unless at least one status check is enabled," so strict mode with an empty check list does nothing.

The decision#

Use strict checks on a branch where pull requests often change shared interfaces and merges are infrequent enough that authors rarely have to catch up twice. Use a merge queue instead when the branch is busy and your plan offers one. Leave checks loose only where a post-merge failure on the base branch is cheap to notice and revert, and make sure something runs on every push to that branch so the failure is noticed at all.

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