How to Delete a Merged Pull Request on GitHub
Introduction
In a private personal project, I accidentally merged a Pull Request containing a commit with credential information that I used for local debugging. Although I was able to delete the branch and the commit, the credential information remained visible in the Pull Request.
Since it’s a private repository for personal use, I could reset the credentials and ignore the issue. However, the thought of sensitive information lingering on the page was unsettling. Despite there being no option to delete the Pull Request directly from the page, I managed to find a way to remove it, which I will document here.
Conclusion
You can delete a Pull Request by contacting GitHub Support.
Steps
Go to the GitHub Support page and create a ticket. Select “Remove data from a repository I own or manage.”
On the next page, select “Delete a pull request.”
In the form that appears, select your account and the repository in question, then describe the issue and request the deletion. Despite GitHub Copilot automatically responding with some documentation links, I ignored it and submitted the ticket, as my request was specifically about deleting the Pull Request.
Here is the message I sent:
Hello,
I accidentally merged a Pull Request that contained credentials in one of the commits. I have removed these commits from the main branch by force-pushing, but the credentials are still visible in the Pull Request history.
Could you please assist with deleting this Pull Request to prevent the credentials from being exposed?
Here is the URL to the Pull Request: [URL of the Pull Request]
Thank you for your help.
Best regards,
[My Name]
Twelve minutes later (quick response!), I received the following reply, and the Pull Request had been deleted. Thank you for your help.
Hi [My Name],
Thank you for reaching out to GitHub Support.
I have deleted the PR for you. I hope this helps!
Regards,
[Support Person's Name]
GitHub Support
Conclusion
This resolved my concern about having credentials visible in a Pull Request. However, while it’s possible to delete a Pull Request by contacting support, I realize that this adds to their workload. Even in a private, personal project, I’ll make sure to self-review Pull Requests carefully moving forward.
If you’ve found yourself in a similar situation, take care when merging Pull Requests.