212

How can a pull request on github be cancelled?

Xeoth
  • 1,285
  • 1
  • 11
  • 22
memmons
  • 40,222
  • 21
  • 149
  • 183

7 Answers7

207

GitHub now supports closing a pull request

Basically, you need to do the following steps:

  1. Visit the pull request page
  2. Click on the pull request
  3. Click the "close pull request" button

Example (button on the very bottom):

github close pull request

This way the pull request gets closed (and ignored), without merging it.

Avatar
  • 14,622
  • 9
  • 119
  • 198
lifeisstillgood
  • 3,265
  • 2
  • 21
  • 22
  • 49
    It is very far down on the page. Just scroll aaaall the way down. – larsr Apr 06 '13 at 21:31
  • 2
    Tip: The close button is on the pull request on the *target* repo. You won't find it on the page for the pull request in the source repo. – Mars Sep 16 '14 at 16:07
  • 6
    Is there a way to delete a PR not just close? Thanks. – f01 Oct 01 '15 at 11:06
  • small correction needed in github help page , click on original repo for which you've submitted pull request. Click on the name of PR and scroll to be bottom. – vikramvi Jul 22 '16 at 10:23
  • 5
    The question was how to "DELETE" the pull request, not how to close it, – sea26.2 Mar 07 '21 at 00:15
17

In the spirit of a DVCS (as in "Distributed"), you don't cancel something you have published:
Pull requests are essentially patches you have send (normally by email, here by GitHub webapp), and you wouldn't cancel an email either ;)

But since the GitHub Pull Request system also includes a discussion section, that would be there that you could voice your concern to the recipient of those changes, asking him/her to disregards 29 of your 30 commits.

Finally, remember:

  • a/ you have a preview section when making a pull request, allowing you to see the number of commits about to be included in it, and to review their diff.
  • b/ it is preferable to rebase the work you want to publish as pull request on top of the remote branch which will receive said work. Then you can make a pull request which could be safely applied in a fast forward manner by the recipient.

That being said, since January 2011 ("Refreshed Pull Request Discussions"), and mentioned in the answer above, you can close a pull request in the comments.
Look for that "Comment and Close" button at the bottom of the discussion page:

https://github-images.s3.amazonaws.com/blog/2011/pull-refresh.png

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 4
    Marking this as correct. After more researching I found a reference on github itself that says pull requests can't be canceled. While I understand the theoretical argument you are making against even having the option, practically the pull request is nothing more than a link added to a database. So, in fact you _should_ be able to cancel the request -- we are not talking about email here, so the expectation should not be that we must follow the same design pattern as email. – memmons Mar 22 '11 at 14:48
  • 1
    @Harkonian: I full agree with your argument: source and destination are on the GitHub webapp server side, so any action (like a cancel) should be possible. But currently, you would need to make a "request for enhancement" to GitHub team in order to ask for that feature. – VonC Mar 22 '11 at 15:14
9

If you sent a pull request on a repository where you don't have the rights to close it, you can delete the branch from where the pull request originated. That will cancel the pull request.

Roch
  • 21,741
  • 29
  • 77
  • 120
8

Go to conversation tab then come down there is one "close pull request" button is there use that button to close pull request, Take ref of attached image

Mohit
  • 885
  • 9
  • 7
6

If you have opened PR on gitHub, but it is not merged yet and you want to get rid off it, not just close, do this simple command:

git push origin --delete <your branch name of your PR>
Ivan S.
  • 94
  • 1
  • 5
4

I had the same problem. What I did is

  1. Go to the Pull Request page.
  2. Check the commit using the checkmark on left of the commit.
  3. From the dropdown "Mark as" click Close.

That's all.

Faysal Ahmed
  • 149
  • 4
0

Super EASY way to close a Pull Request - LATEST!

  1. Navigate to the Original Repository where the pull request has been submitted to.
  2. Select the Pull requests tab
  3. Select your pull request that you wish to remove. This will open it up.
  4. Towards the bottom, just enter a valid comment for closure and press Close Pull Request button

enter image description here

RICHARD ABRAHAM
  • 2,218
  • 20
  • 26