Read Anthropic’s case study about Graphite Reviewer

Delete pull requests in GitHub

Kenny DuMez
Kenny DuMez
Graphite software engineer

This guide explores how to close pull requests, delete branches related to closed pull requests, and delete specific files within pull requests. We'll also discuss the differences between closing and deleting PRs, and how to reopen them if necessary.

Closing a pull request:

  • Closing a pull request in GitHub signifies that the PR is complete, rejected, or no longer relevant, but it does not delete the PR from GitHub. It remains in the repository's history and can be reopened or referenced in the future.
  • To close a pull request, you simply change its status to "closed" on the GitHub interface, indicating that the PR should not be merged into the base branch.

Deleting a pull request:

  • GitHub does not provide a direct way to delete a pull request because it serves as a part of the project's historical documentation. However, you can delete the branch associated with a closed pull request, which effectively removes the proposed changes from being merged.
  • Deleting the branch of a closed pull request is common to tidy up your repository once the changes are merged or definitively rejected.
  1. Navigate to the pull request: Go to the "Pull Requests" section of your repository.
  2. Choose the pull request to close: Select the pull request you wish to close.
  3. Close the pull request: At the bottom of the pull request page, click the "Close pull request" button to close it without merging the changes.

If a closed pull request needs to be reconsidered, you can easily reopen it:

  1. Navigate to the closed pull request: Go to the "Closed" tab under "Pull Requests".
  2. Select the pull request: Find the pull request you wish to reopen.
  3. Reopen the pull request: Click the "Reopen pull request" button to move it back to an open state.

Once a pull request is merged or closed, you might want to delete the branch to clean up your repository:

  1. Navigate to the pull request: Access the closed or merged pull request.
  2. Delete the branch: If the pull request was merged, you can delete the branch directly from the pull request page. If you closed the pull request or it was merged successfully, you can delete the branch by clicking the "Delete branch" button.

If you need to remove a file from an existing pull request:

  1. Check out the branch associated with the pull request: Use Git to switch to the branch:
    Terminal
    git checkout feature-branch
  2. Delete the file: Remove the file using the git command:
    Terminal
    git rm file-to-delete.txt
  3. Commit the change: Commit your changes with a message explaining the deletion:
    Terminal
    git commit -m "Remove unnecessary file"
  4. Push the changes: Update the branch on GitHub, which will automatically update the pull request:
    Terminal
    git push origin feature-branch

To remove an open pull request without merging:

  1. Close the pull request: Follow the steps above to close the pull request without merging it.
  2. Delete the branch: As described above, you can delete the branch to effectively remove the changes proposed in the pull request.

For more information, see the official GitHub documentation.

Git inspired
Graphite's CLI and VS Code extension make working with Git effortless.
Learn more

Graphite
Git stacked on GitHub

Stacked pull requests are easier to read, easier to write, and easier to manage.
Teams that stack ship better software, faster.

Or install our CLI.
Product Screenshot 1
Product Screenshot 2