Undoing Things

Setting The HEAD To A Previous Commit

To checkout to a given commit, run

$ git checkout _COMMIT_ID_

At this point you can create a branch and start to work from this point on

$ git checkout -b _BRANCH_NAME_

To move back to a commit and effectively lose the later commits

$ git reset --hard _COMMIT_ID_

This will destroy any local modifications. Don't do it if you have uncommitted work you want to keep.

To push the changes to the remote after a hard reset you will need to run

$ git push -f _REMOTE_ _BRANCH_