Resetting Your Github Fork
Let’s say I want to contribute to a project on github. The project repository is at wp-cli/wp-cli. First I fork it, and then clone the resulting repository, scribu/wp-cli:
git clone --recursive git@github.com:scribu/wp-cli.git cd wp-cli
Now, I make some commits to master, push them to my fork and open a pull request. Piece of cake:
git commit -m "awesome new feature" git push
But, what happens if my pull request is rejected or only certain commits are accepted? I’m left with a dirty master branch. Oh noes!
There are two ways of solving this:
A. Delete my fork and create it again via the github interface. Can’t get any easier than that.
B. Use git reset:
git remote add upstream git://github.com/wp-cli/wp-cli.git git fetch upstream git branch backup git reset --hard upstream/master git push --force
If I made a mistake, I can rescue my commits by calling git checkout backup.



