Skip to content

Instantly share code, notes, and snippets.

@nahurst
Last active December 24, 2015 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nahurst/6799432 to your computer and use it in GitHub Desktop.
Save nahurst/6799432 to your computer and use it in GitHub Desktop.
Undoing things on git
git reset --soft HEAD^ # when you just committed something you didn't mean to and you want to change the contents and the message
git commit --amend # when you want to change the commit message you just made
git reset file # when you have a file staged for delete that you want to unstage
git checkout file # when you want to restore that file you unstaged file to it's original version
git reset HEAD file # when you want to unstage a staged change
git reset --soft "HEAD^" # when you just committed something, but you want to undo the commit and revert everything to how it was staged before the commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment