Delete a closed pull request from GitHub
Asked Answered
C

6

395

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?

Cloris answered 19/8, 2013 at 15:56 Comment(4)
No. You can only close it.Fyke
GitHub account and UI related questions are better for WebApps.StackExchange.com or directly to their supportNahamas
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.Lon
Great Q and another victim of the SO mandarins. Great answers too.Gulfweed
P
413

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

Preinstruct answered 19/8, 2013 at 16:16 Comment(8)
They(Github staff) only delete pull requests that contain sensitive data.Parenthesize
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."Echolalia
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'sPhosphoresce
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.Sac
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. :)Restharrow
Guess I'll have to add my SSN + date of birth to get this PR deleted :(Aluminium
I assume that's a GitHub philosophy, since you can delete that info in gitReinaldo
support.github.com/request >> Remove data from a repository I own or control >> Remove pull requestsSimilarity
R
45

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!

Rhianna answered 14/8, 2020 at 2:43 Comment(6)
This works even if the repo is not a fork. Just make sure you back up the branch first.Mancuso
This does not actually delete the PR. It simply closes the PR and the PR still remains visible in logsBaseboard
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-219088644Bergman
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.Fecundity
The PR is still listed, but at least without a code pushed there before.Monarski
Unfortunately if used on a non-forked PR this technique doesn't completely clear out the old code. You'll end up with a message like this at the bottom of the closed PR some-user force-pushed the some-branch branch from 12bcd456 to 455abc 2 minutes ago Those are the SHAs and provide a direct link to the code that was 'removed'Mayhem
C
35

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."

Cecil answered 8/5, 2020 at 22:4 Comment(1)
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!Kmeson
S
5

Github now uses a virtual assistant to delete the pull request for you. If you go to:

https://support.github.com/contact

You can tell the virtual assistant that you want to delete a pull request. It will ask you for the url of the pull request and a few other questions then notify you when

Stencil answered 2/2, 2024 at 13:17 Comment(0)
O
3

Unlike other experiences I've seen on this post, asking GitHub to delete my Pull Request on a repository I do not control, I got this reply:

Hi (username),

No problem! I've gone ahead and deleted that pull request for you. I’ve also cleared the cache of your repository.

Of course, we still recommend changing any leaked sensitive data as soon as possible, if you haven't already.

Feel free to reach out again if you need anything else!

Cheers,

So, the support request did work. I had no personal data on the PR - I just asked for a deletion. I recommend giving it a try.

Osteoma answered 28/12, 2023 at 12:11 Comment(0)
K
-3

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.

Kersten answered 6/1, 2022 at 4:43 Comment(5)
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.Sumo
git has no problem with deleting branches or commits. It's GitHub that won't allow deleting PRs here.Photoneutron
This is not working, even for just removing content, although the pr look empty, you can still compare the force push "commit diff"Leishaleishmania
just an additional hint: don't close the PR first, then it will ignore anything you do and won't let you reopen it either after you mess with the branchAnglian
Github still has a reference to the PR - thus is not a safe way to remove PII/PHISaltworks

© 2022 - 2025 — McMap. All rights reserved.