169
  • I made some changes
  • I submitted a pull request
  • The pull request was accepted and merged.
  • We found a bug
  • The changes were removed again (force push to 1 commit before) whilst I fixed the bug.

I've now fixed the bug and want to resubmit the pull request with 1 extra commit. Is there any way to reopen the pull request or update it, or do I have to create a new pull request, type out the description etc again? Gitorious has this feature and we've recently moved to GitHub.

Michael Parker
  • 7,180
  • 7
  • 30
  • 39
  • 1
    I was in similar situation today i.e. used "Merge Pull Request" button which by default merge the changes into target branch and close the PR. I later discovered a bug in testing which I wanted the original developer to fix. I wanted a way to reopen this PR so that more commits can be added to this same PR but could not as there is no button for reopening the PR. – SBirthare Feb 12 '16 at 07:57

8 Answers8

168

The answer seems to be: You can't.

Once a pull request is merged and closed, it is locked forever and cannot be reopened. If your pull request is merged, closed, then your changes are pulled out (via force pushing backwards to before the merge), you will need to add commits to the branch and create a new pull request, copying all the details over and probably providing a link to the original pull request to manually save the history.

Might be a nice feature request for future GitHub.

Michael Parker
  • 7,180
  • 7
  • 30
  • 39
  • 11
    I don't know when it was changed, but you can comment & reopen closed PRs now. – LB-- Apr 28 '13 at 03:00
  • 24
    @LB, it doesn't seem you can reopen PRs that have been closed *and merged*. – A Kaptur Oct 14 '13 at 22:25
  • 2
    You actually can. Assuming that you have reverted the initial merge, you can make a branch of the main repo, and on this new branch just revert the commit that was reverting the merge. – Costin_T Dec 17 '15 at 08:04
  • 15
    @SsjCosty But that is not reopening a closed & merged PR. You can always open new pull requests, which is what your solution requires. – Adam Grant Jul 05 '17 at 16:59
  • 4
    _"Might be a nice feature request for future GitHub."_ Actually, no, it wouldn't. If PRs could be redefined after creation, then people checking out the PR at different times, would potentially drift. Just create another PR and "mention" the prior one in text. If you want to reference some sort of milestone, it's not PRs to look at, that would be tags. – Scott Prive May 29 '20 at 14:30
  • 3
    @ScottPrive let me clarify the situation. The original PR was merged into a branch that no longer exists. Master has been forced pushed backwards in the past so the merge commit no longer exists. There is no use looking at a merged PR from a branch to master where the merge commit doesnt exist any more, and having 2 identically named PRs from + to the same branches is more confusing than simply re-opening the original. – Michael Parker May 29 '20 at 22:04
10

I just successfully reopened a pull request by

  1. Commenting on the pull request
  2. Clicking the 'Submit and re-open' button which appeared on the comment form.
Tim Lovell-Smith
  • 15,310
  • 14
  • 76
  • 93
  • 2
    I haven't managed to replicate this - can you explain the steps required to see this behaviour? I tried commenting on a closed pull request (didnt work), commenting on a closed pull request and pushing to the branch it was pulling in (didnt work). Anything else to try? Is the pull request required to be merged then later unmerged somehow? – Michael Parker Nov 16 '12 at 15:05
  • I don't know what the hidden requirement making a difference is. Could be any of (have submitted new change for pull request, am member of project owners, other...) – Tim Lovell-Smith Nov 19 '12 at 01:01
  • 2
    I've now tried everything you mentioned, still can't see it. I am the repo owner. Searching google for "Submit and re-open GitHub" provides a single hit - this page. Any further information would be extremely helpful. Was your pull request initially denied? – Michael Parker Nov 21 '12 at 16:36
  • 74
    I can replicate this with unmerged pull requests - but that's not what this thread is about. – Dan Tello Aug 13 '13 at 21:04
  • 6
    Yeah, he is referring to closed pulls, not merged pulls. – loujaybee Oct 29 '15 at 08:57
4

You can use the revert action:

enter image description here

It will create another pull request undoing all the changes did in the merged PR.

William Weckl
  • 2,435
  • 4
  • 26
  • 43
  • This is not the best practice :) – antonbormotov Dec 28 '17 at 12:24
  • 4
    @antonbormotov can you suggest a better approach? – William Weckl Jan 06 '18 at 13:37
  • Let's assume, we had merged pr with commits (mA and mB) to stable branch that we want to revert. After merging "revert" pr, history will look like tree of commits: X-Y-mA-mB-C-D-rA-rB-E-F. Why do you want to see all of these commits in history, that apply changes (mA, mB) and then cancel them (rA, rB)? It would be better to rebase and remove those "bad" commits mA and mB from stable branch and keep history clean. Of course, it makes sense if merge was relatively recent. – antonbormotov Jan 07 '18 at 08:02
  • 1
    Not only will the history look ugly, you also can no longer simply merge the reverted commits back in when you are ready. – Michael Sep 06 '18 at 20:07
  • I had somewhat similar scenario with minor difference. I had a PR that I needed to review and was supposed to wait for another PR to be merged. But I didn't see it and merged this PR prematurely. I actually did what @WilliamWeckl suggested. But now I want to create the same PR with same changes that were created originally. But when I am creating the PR the master branch is showing no difference, though when I see individual files they are different. Any thoughts? – Vikas Jul 18 '19 at 02:16
  • I think this "Revert" button serves a different purpose than what the OP originally is asking which is reopening for *adding extra commits* to the original PR. Instead, this "Revert" button is actually "undoing" the PR and start the entire thing over? – Shawn Oct 07 '22 at 20:50
4

I've tried all of the tricks & tips. Simply - you can't re-open it.

It is what it is. (even that I'm sad they haven't come up with this)

Matthew Husák
  • 427
  • 4
  • 12
4

Edited by the author to add: It's 2023, and consensus seems to be this never works.


Well, it's 2021 and—almost a decade later—to my dismay, stupor, and joy, a simple gh pr reopen N¹ did reopen my PR—in a situation which I know was un-reopenable through UI before (or so I believe). ¯\_(ツ)_/¯

May this work for you too!

(¹) gh being GitHub’s official command line tool.

Dato
  • 354
  • 3
  • 12
  • 1
    Was the PR already merged before you tried to reopen it? – Michael Parker Dec 27 '21 at 14:41
  • 2
    Yes. (Not with the merge button: the base branch had been accidentally pushed to including the commit from the PR.) The base branch was later force-pushed back to its original state, but the PR could not be reopened, not by any means I tried. – Dato Dec 28 '21 at 15:05
  • 4
    `Pull request #20 (LOTH Prose) can't be reopened because it was already merged` - did you have any extra commits or anything? – mcbain83 Mar 31 '22 at 05:05
  • Mine was already merged and the above trick didn't work for me either. – blackcatweb May 19 '22 at 13:57
  • fwiw you can still push to the branch and then open a new pull request on the updated branch. I did this (even after deleting the branch) by first pushing to it then listing branches with "view all branches" in the branches dropdown in the code tab. There's an option to create a pull request for each branch. – drevicko Nov 22 '22 at 05:04
  • 1
    Doesn't work on PRs already merged, even though the base was reset to before the merge commit. – Hannes Mar 03 '23 at 05:47
  • Yeah, didn't work for me (despite the PR having been merged automatically by pushing to the base branch and having force-pushed the branch back)... got: `X Pull request #37 (Update to node 18) can't be reopened because it was already merged` – Nolan Amy Jul 21 '23 at 05:45
3

Just derive a new branch from the existing branch where you have done extra 1 commit. From there submit the pull request.

Siva Gollapalli
  • 626
  • 6
  • 20
3

You could just revert a reverted PR, this should have all the changes that was reverted from original PR.

Vlada
  • 258
  • 4
  • 8
1

I managed to reopen it by:

  1. Restoring the base branch
  2. Reopen and Comment
seebi
  • 488
  • 5
  • 9