Delete a closed pull request from GitHub

215,919

Solution 1

There is no way you can delete a pull request yourself -- you and the repo owner (and all users with push access to it) can close it, but it will remain in the log. This is part of the philosophy of not denying/hiding what happened during development.

However, if there are critical reasons for deleting it (this is mainly violation of Github Terms of Service), Github support staff will delete it for you.

Whether or not they are willing to delete your PR for you is something you can easily ask them, just drop them an email at [email protected]

UPDATE: Currently Github requires support requests to be created here: https://support.github.com/contact

Solution 2

5 step to do what you want if you made the pull request from a forked repository:

  1. reopen the pull request
  2. checkout to the branch which you made the pull request
  3. reset commit to the last master commit(that means remove all you new code). Command: git reset --hard commit_hash_here
  4. git push --force
  5. delete your forked repository which made the pull request

And everything is done, good luck!

Solution 3

This is the reply I received from Github when I asked them to delete a pull request:

"Thanks for getting in touch! Pull requests can't be deleted through the UI at the moment and we'll only delete pull requests when they contain sensitive information like passwords or other credentials."

Solution 4

It's very easy actually:

You can empty it, that's the best you could do.

  1. Go to your local

  2. Copy your local branch unwanted-branch (against which the PR was opened) to a new branch new-branch. This copying is relevant if you want to back it up for any reason. Otherwise go to step 3.

    • $ git branch -b new-branch
    • $ git merge unwanted-branch
    • $ git push
  3. Empty the unwanted-branch

    • $ git checkout unwanted-branch
    • $ git reset --hard HEAD~n #n is the number of commit the branch has
    • $ git push -f

Enjoy, your PR is empty and closed now ;). Go to remote and delete the unwanted-branch if it bothers you.

Share:
215,919

Related videos on Youtube

Aristona
Author by

Aristona

Hi there! I'm Anıl and I live in Kastamonu, Turkey. Although my main expertise is on the backend, I usually do frontend, mobile development and game development too.

Updated on January 06, 2022

Comments

  • Aristona
    Aristona 12 months

    I accidentally made a wrong pull request and ended up closing the request myself. It's in a closed state right now but it's accessible via direct URL and showing on my activity bar.

    Is there any way to delete a pull request completely so it's no longer accessible via URL or shows up on your activity history?

    • Eugene Ryzhikov
      Eugene Ryzhikov over 9 years
      No. You can only close it.
    • random
      random over 9 years
      GitHub account and UI related questions are better for WebApps.StackExchange.com or directly to their support
    • Machta
      Machta almost 6 years
      You can get rid off all pull requests (and other things like LFS files) by deleting and recreating the repository. Most of the time you cannot afford this but it can help if you mess up early on.
    • RichieHH
      RichieHH almost 3 years
      Great Q and another victim of the SO mandarins. Great answers too.
  • Yousha Aleayoub
    Yousha Aleayoub about 5 years
    They(Github staff) only delete pull requests that contain sensitive data.
  • Justin Domnitz over 4 years
    Some useful information: help.github.com/articles/… "... you can permanently remove all of your repository's cached views and pull requests on GitHub by contacting GitHub Support."
  • Erik Aronesty
    Erik Aronesty over 3 years
    So sad. I submit a bad PR about once every week because I'm maintaining a forked repo and the default PR is to the head. At some point we'll need to branch off from the mai, but for now... zillion closed pr's
  • MaXi32
    MaXi32 about 3 years
    I know this is an old question but have you tried delete your github account and re-create it? From the documentation, when you delete your account, github said you automatically delete all your pull request made in other repository. But this means you have to start your "new life" on github. I think this is the only way. Hopefuly someone open this question and put this answer below.
  • Marc.2377
    Marc.2377 about 3 years
    For what it's worth, I contacted GitHub support today to request deletion of a PR that was submitted by mistake to another repository where I'm an admin. They deleted it for me and were super nice. :)
  • Neel
    Neel over 2 years
    Guess I'll have to add my SSN + date of birth to get this PR deleted :(
  • joel
    joel over 2 years
    I assume that's a GitHub philosophy, since you can delete that info in git
  • slajma
    slajma about 2 years
    This works even if the repo is not a fork. Just make sure you back up the branch first.
  • Ishan Jain
    Ishan Jain over 1 year
    This does not actually delete the PR. It simply closes the PR and the PR still remains visible in logs
  • Darshan L
    Darshan L over 1 year
    An important point in this approach is to make sure you reopen the PR before you force push. ie step1 is a must before you go to next step. Otherwise, once you have force pushed your changes, you cant reopen the PR. If in case, you didnt perform step1 and force pushed, still you can reopen with tedious workaround - github.com/isaacs/github/issues/361#issuecomment-219088644
  • kamae
    kamae about 1 year
    It did not work even though I followed the steps including the step 1. The PR becomes just a closed state and still listed in the closed PR list.
  • kyakya
    kyakya about 1 year
    support.github.com/request >> Remove data from a repository I own or control >> Remove pull requests
  • Yılmaz Alpaslan
    Yılmaz Alpaslan 11 months
    This empties the PR in case sensitive data was publishes with the PR, but OP wants to completely delete the PR in both contribution activity and closed PRs list of the repository. Apparently it's not possible to do so.
  • edam
    edam 11 months
    Yes, git ethics won't allow it.
  • Ordoshsen
    Ordoshsen 9 months
    git has no problem with deleting branches or commits. It's GitHub that won't allow deleting PRs here.
  • internetdotcom
    internetdotcom 9 months
    So the solution for this missing feature is to edit a pull request to add a social security number to it -- it may not have to be your own!
  • Jonatan Cloutier
    Jonatan Cloutier 7 months
    This is not working, even for just removing content, although the pr look empty, you can still compare the force push "commit diff"