Skip to content

Instantly share code, notes, and snippets.

@space11
Created November 15, 2018 11:50
Show Gist options
  • Save space11/95620d11752be1dfbaf22c43fe08dcb8 to your computer and use it in GitHub Desktop.
Save space11/95620d11752be1dfbaf22c43fe08dcb8 to your computer and use it in GitHub Desktop.
Git - undo commit

How can I undo the last commit? Note the --soft flag: this makes sure that the changes in undone revisions are preserved. After running the command, you'll find the changes as uncommitted local modifications in your working copy. $ git reset --soft HEAD~1

If you don't want to keep these changes, simply use the --hard flag. Be sure to only do this when you're sure you don't need these changes anymore. $ git reset --hard HEAD~1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment