Learning center

Should new commits dismiss an approval on a pull request?

Dismiss stale approvals on branches where an approval must describe the diff that actually merges, such as a shared service's default branch. The price is re-review: GitHub also dismisses an approval when someone clicks Update branch or the merge base moves, so pair the setting with a merge queue instead of strict up-to-date checks on busy branches.

What the setting does#

With required reviews on, the setting Dismiss stale pull request approvals when new commits are pushed ties each approval to a snapshot. According to the docs, GitHub "records the state of the diff at the point when a pull request is approved," and that state "represents the set of changes that the reviewer approved." If the diff changes from that state, "the approving review is dismissed as stale, and the pull request cannot be merged until someone approves the work again." About protected branches

The trigger is a change to the diff, and the docs give three examples of how it happens: a contributor "pushes new changes to the pull request branch or clicks Update branch, or because a related pull request is merged into the target branch." A separate note adds that approvals are dismissed "if the merge base introduces new changes after the review was submitted," where the merge base is "the last common ancestor between the topic branch and the base branch." The same note warns that, with this setting on, pushing a hand-made merge commit straight to the protected branch fails "unless the contents of the merge exactly match the merge generated by GitHub for the pull request." Available rules for rulesets

Rulesets expose the same switch as dismiss_stale_reviews_on_push, described in the REST reference as "New, reviewable commits pushed will dismiss previous pull request review approvals." Create a repository ruleset

A fictional pull request that CI and the reviewer both pass#

Suppose a fictional repository, acme/billing, requires one approval on main. Ana opens a pull request that changes how failed card charges are retried. Ben reads the retry code, asks one question, and approves.

Ana then pushes a second commit. It raises max_attempts in config/retry.yaml from 3 to 12, because a test was flaky locally. The unit tests mock the payment provider, so they pass with any value. CI goes green.

Without dismissal, Ben's approval still counts, and Ana can merge a change to production retry volume that nobody else has read. CI had no reason to object, and the reviewer reviewed exactly what he was shown. With dismissal on, the second commit changes the diff, Ben's approval is dismissed, and the merge box asks for a new approval. Ben opens the pull request again and sees config/retry.yaml as new.

To make that second look cheap, GitHub unmarks a file the reviewer marked Viewed "if the file changes after you view the file," so Ben can skip the files he already read. Marking a file as viewed

What it does not catch#

Dismissal forces a second approval. It does not make the second approval a second reading. A reviewer who clicks approve again without opening the new diff restores the state the setting was meant to prevent.

It also does nothing about the content of the first approval. Ben approved retry code he understood. Had the max_attempts change been in the first commit and he had skimmed past it, dismissal would not have changed anything. Nor does it stop the reviewer from pushing a commit of their own and then approving it, because their approval comes after their push and is not stale. Last-push approval covers that case.

The cost: approvals that expire for reasons the author did not choose#

Every dismissal is a round trip to a reviewer, and some of them follow changes the author did not make. When a branch requires strict status checks, the author must bring the head branch up to date before merging; the docs say the strict mode means "you'll need to bring the head branch up to date after other collaborators update the target branch." Clicking Update branch is one of the dismissal triggers the docs list, so on a busy main the sequence becomes approve, update, dismissed, approve again. Each new merge to main can restart it.

A merge queue removes most of that loop. The docs describe it as giving "the same benefits as the Require branches to be up to date before merging branch protection" without requiring "a pull request author to update their pull request branch." Require merge queue The guide to strict status checks compares the two.

Decide and configure#

Turn dismissal on when a commit pushed after approval could change behavior that tests do not pin down: configuration, limits, permissions, infrastructure definitions, migrations. Those are exactly the files where a late edit passes CI. Leave it off on branches where approvals are a light check and every merge is cheap to revert, and consider last-push approval there, since it keeps old approvals and asks only that someone other than the last pusher approve the final commits.

In a ruleset, the setting sits in the pull_request rule. This body, sent to POST /repos/acme/billing/rulesets, applies it to the default branch with one required approval:

{
  "name": "main-reviews",
  "target": "branch",
  "enforcement": "active",
  "conditions": {
    "ref_name": { "include": ["~DEFAULT_BRANCH"], "exclude": [] }
  },
  "rules": [
    {
      "type": "pull_request",
      "parameters": {
        "required_approving_review_count": 1,
        "dismiss_stale_reviews_on_push": true,
        "require_code_owner_review": false,
        "require_last_push_approval": false,
        "required_review_thread_resolution": false
      }
    }
  ]
}

In a classic branch protection rule, select Require a pull request before merging and Require approvals, then Dismiss stale pull request approvals when new commits are pushed. Managing a branch protection rule

Tell authors what to expect: after any push, re-request review from the person whose approval was dismissed, and say in one line what changed. That line is what lets the reviewer review the increment instead of the whole pull request again.

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