Learning center

Last-push approval or stale-approval dismissal: which to require

Require last-push approval when someone other than the last pusher must approve the final commits and collecting every approval again is too costly. If an approved pull request could be extended with content nobody reads, GitHub's docs point you to dismissing stale reviews, because last-push approval leaves older approvals counted.

What last-push approval requires#

The option Require approval of the most recent reviewable push means "the most recent reviewable push must be approved by someone other than the person who pushed it," so that "at least one other authorized reviewer has approved any changes." About protected branches

GitHub introduced it on 20 October 2022. The changelog explains the counting: "the most recent user to push their changes will need a pull request approval regardless of the Require approvals branch protection," and when one approval is required, "someone other than the last user to push their changes will also need to approve." New Branch Protections: Last Pusher and Locked Branch

The docs present it as a lighter alternative to dismissal: "with this option, 'stale' reviews are not dismissed, and the pull request remains approved as long as someone other than the person who made the most recent changes approves it." They also say which to prefer when an approved pull request might be "hijacked," where "unapproved content is added to approved pull requests": dismiss stale reviews. Available rules for rulesets

Two fictional pushes and what each setting does#

Suppose a fictional repository, acme/web, requires two approvals on main. Dana opens a pull request that reworks the checkout page. Eli and Fay both approve. Two different things can happen next.

In the first case, Dana pushes one more commit that adds a third-party script tag to the checkout template. In the second, Eli, one of the approvers, pushes a small fix to Dana's branch himself and then approves again.

Setting on mainAfter Dana's late pushAfter Eli pushes and re-approves
NeitherEli's and Fay's approvals still count; Dana can mergeEli's approval counts for his own commit; the pull request can merge
Dismiss stale approvalsBoth approvals are dismissed; two new approvals neededFay's approval is dismissed; Eli's new approval comes after his push and counts, so Fay or someone else must approve once more
Last-push approvalBoth approvals still count, but someone other than Dana must approve after her pushEli's approval does not satisfy the rule; someone other than Eli must approve after his push
BothBoth approvals are dismissed; two new approvals neededFay's approval is dismissed; someone other than Eli must approve after his push

The second column is where last-push approval earns its place. Dismissal alone does not stop a reviewer from writing a commit and approving it in the same sitting: their approval postdates their push, so it is not stale. Last-push approval refuses exactly that. In the first column, last-push approval still requires a fresh look at Dana's commit, but only from one person. Fay's earlier approval keeps counting toward the two even though she never saw the script tag.

What it does not catch#

Last-push approval checks who approved, not what they read. Eli can re-approve Dana's late commit after glancing at the title, and the rule is satisfied.

It also cannot separate two people who act together. Any second writer's approval clears it. And because the author of a pull request cannot approve it (the docs state that "pull request authors cannot approve their own pull requests"), a push from a reviewer to someone else's pull request always needs a third person. Approving a pull request with required reviews

The cost#

The friction lands on small teams and on collaborative pull requests. With two active maintainers, one fixing the other's pull request leaves nobody who can approve: the author cannot, and the fixer is the last pusher. You either wait for a third reviewer or ask the author to push the fix instead.

Like dismissal, the setting also changes how merges can reach the branch. With either option on, "manually creating the merge commit for a pull request and pushing it directly to a protected branch will fail, unless the contents of the merge exactly match the merge generated by GitHub," and approvals are dismissed as stale "if the merge base introduces new changes after the review was submitted." About protected branches

Decide and configure#

Choose by the failure you are trying to stop:

  1. If reviewers sometimes push fixes and approve their own fixes, turn on last-push approval.
  2. If approved pull requests might gain unreviewed commits, turn on stale-approval dismissal as described in the dismissal guide.
  3. If both happen, turn on both. They combine, and the docs treat them as independent options.
  4. If a pull request routinely gathers four or five approvals from different teams, prefer last-push approval over dismissal, so a late push costs one re-approval instead of five.

In a ruleset, set require_last_push_approval in the pull_request rule. The REST reference describes it as "whether the most recent reviewable push must be approved by someone other than the person who pushed it." Create a repository ruleset

{
  "type": "pull_request",
  "parameters": {
    "required_approving_review_count": 2,
    "dismiss_stale_reviews_on_push": false,
    "require_code_owner_review": false,
    "require_last_push_approval": true,
    "required_review_thread_resolution": false
  }
}

If the repository also lets Copilot open pull requests, the option interacts with the extra approval for unattributed Copilot pull requests: when that extra approval is cleared, "at least one approval must cover the last push and come from someone other than Copilot." Additional approval for unattributed Copilot pull requests The Copilot extra approval guide covers that decision.

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