Skip to content

Instantly share code, notes, and snippets.

@warolv
Created October 10, 2013 12:37
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save warolv/6917623 to your computer and use it in GitHub Desktop.
Save warolv/6917623 to your computer and use it in GitHub Desktop.
Undo Changes
git reset --soft HEAD^ -> undo last commit and save changes
git reset --hard HEAD~1 -> undo last commit and remove changes
git reset --hard HEAD~2 -> undo 2 last commits and remove changes
git revert commit-hash -> create new commit which reverts last commit
git checkout . -> remove all uncommitted changes
git checkout filename -> undo changes in specific file
git clear -df -> remove all untracked files
git rm filename -> remove file from index, after your did git add filename
git commit --amend -> change message of last commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment