Pull Requests (PRs) are essential for collaboration on GitHub—they help you propose, review, and merge changes into a project. But what if you open a pull request by mistake, or you no longer need it? A common question developers ask is: “Can I delete a pull request in GitHub?”
In this post, we’ll explore the answer, provide alternatives, and guide you on best practices for managing pull requests cleanly.
❓ Can You Delete a Pull Request in GitHub?
Short answer: No, GitHub does not allow users to delete a pull request outright.
Once a pull request is created, it becomes part of the repository’s history and cannot be permanently removed via the GitHub interface. However, you can close a pull request, which effectively marks it as no longer active.
✅ How to Close a Pull Request in GitHub
If you want to remove a pull request from active consideration, here’s how to close it:
Step 1: Navigate to the Pull Request
- Go to your repository on GitHub.
- Click the “Pull requests” tab.
- Select the pull request you want to manage.
Step 2: Close the Pull Request
- Scroll to the bottom of the pull request.
- Click the “Close pull request” button.
This will mark the PR as closed and move it out of the list of open pull requests.
💡 Note: Closed pull requests are still visible under the “Closed” tab and can be reopened if needed.
🧹 Optional: Delete the Branch (If You Created One)
If the pull request came from a feature branch you created, you can delete that branch to clean up your repository:
- After closing the PR, GitHub may show an option to “Delete branch”.
- You can also delete the branch manually by going to the Branches tab in the repository.
From the command line:
git push origin --delete your-branch-name
🔐 What About Sensitive Information?
If the pull request includes sensitive data (e.g., API keys, passwords) that was committed by mistake:
- Close the PR immediately.
- Delete or rotate any exposed secrets.
- Use GitHub’s BFG tool or
git filter-branch
to remove sensitive content from history. - Force-push corrected history (if needed).
- Contact GitHub support if the situation requires further remediation.
🧭 Best Practices for Pull Request Management
- Double-check before creating a PR—ensure your changes are ready for review.
- Use drafts for works-in-progress instead of opening a full PR prematurely.
- Name branches clearly to avoid confusion.
- Clean up unused branches regularly.
📝 Summary
Action | What it Does |
---|---|
Close PR | Marks it inactive (recommended) |
Delete branch | Removes the source of the PR |
Delete PR | ❌ Not supported on GitHub |
While GitHub doesn’t support deleting a pull request entirely, closing it and cleaning up the source branch serves the same purpose in most scenarios.