git.
camp

Clean Up Pull Requests

In this video, I walk through the process of cleaning up a pull request that contains a few changes too many.

01 - Clean up Pull Requests from Jesse Shawl on Vimeo.

Or, view the text version

There are three ways to mess up a pull request:

  1. Adding a file that shouldn’t be there.
  2. Editing a file that shouldn’t be edited.
  3. Removing a file that shouldn’t be removed.

Here is how to undo these changes.

1. Adding a file that shouldn’t be there

This one is the easiest to fix. Just remove the file:

$ git rm <file>

2. Editing a file that shouldn’t be edited.

Revert the file back to the upstream’s version:

$ git checkout upstream/master -- <file>

This requires you to have the pull requestee repository as a remote:

$ git remote add upstream git@github.com:USER/REPO.git

3. Removing a file that shouldn’t be removed.

To put back a file you’ve accidentally deleted, use the same method as above:

$ git checkout upstream/master -- <file>

Is there a topic you’d like to see covered in the future? Let me know by opening up an issue on GitHub. Thanks for watching!