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 main | After Dana's late push | After Eli pushes and re-approves |
|---|---|---|
| Neither | Eli's and Fay's approvals still count; Dana can merge | Eli's approval counts for his own commit; the pull request can merge |
| Dismiss stale approvals | Both approvals are dismissed; two new approvals needed | Fay'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 approval | Both approvals still count, but someone other than Dana must approve after her push | Eli's approval does not satisfy the rule; someone other than Eli must approve after his push |
| Both | Both approvals are dismissed; two new approvals needed | Fay'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:
- If reviewers sometimes push fixes and approve their own fixes, turn on last-push approval.
- If approved pull requests might gain unreviewed commits, turn on stale-approval dismissal as described in the dismissal guide.
- If both happen, turn on both. They combine, and the docs treat them as independent options.
- 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.