58

Using the new pull request approval process in Github, if I approve a PR but then a dev pushes a new commit to that branch I'd want the PR to go back to the state it is in to start with (i.e. not approved).

At the moment it stays green but in reality there is code that hasn't been reviewed in the branch.

1

2 Answers 2

54

On GitHub, navigate to the main page of the repository. Under your repository name, click Settings. In the left menu, click Branches. Select the branch you want to restrict using the drop-down menu.

Select Dismiss stale pull request approvals when new commits are pushed.

enter image description here

This dismisses a pull request approval review when a code-modifying commit is pushed to the branch.

Click Save changes.

Ref: https://help.github.com/articles/enabling-required-reviews-for-pull-requests/

6
  • 5
    Follow-up question: what exactly is a "code-modifying commit"? Is there some way to configure certain config files to be "ignored" when deciding whether to dismiss a review as stale?
    – Jeff Gran
    Mar 18, 2019 at 15:54
  • 1
    @JeffGran None that I know of. It was basically about the merge commits which happen when you click "Update branch". It does not dismiss reviews as long as you have no severe conflicts. Mar 19, 2019 at 6:46
  • Can dismiss the PR approval for the new commit changes, but keep it when merging from master branch? Sep 24, 2020 at 13:02
  • Does this also invalidate approval if the branch is rebased?
    – Alper
    Oct 20, 2021 at 11:57
  • This is not available in private repos for free accounts.
    – DBear
    Apr 15, 2022 at 12:57
35

It's not clear from your question if you need this automatically done, or if a manual process is okay too.

In my case a manual solution was fine. We'll just rely on developers to use their judgment on whether a PR should be unapproved.

To manually unapprove a PR, you can go to the comments section where the approval is, and click "show all reviewers". Then choose Dismiss for each approved review.

1
  • Unfortunately it would need to be automatic but thanks for the input! You thought me something :)
    – Force Hero
    Jul 26, 2017 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.