Skip to content

Instantly share code, notes, and snippets.

@zfael
Forked from alexislucena/uncommitLastCommit.md
Created April 19, 2018 17:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zfael/04fd8840161307351ee358d5715580b2 to your computer and use it in GitHub Desktop.
Save zfael/04fd8840161307351ee358d5715580b2 to your computer and use it in GitHub Desktop.
Git: How to uncommit my last commit in git

To keep the changes from the commit you want to undo

$ git reset --soft HEAD^

To destroy the changes from the commit you want to undo

$ git reset --hard HEAD^

You can also say

$ git reset --soft HEAD~2

to go back 2 commits.

If you are on Windows you will need to put HEAD or commit hash in quotes.

$ git reset --soft "HEAD^"
$ git reset --soft "asdf"

Source:
http://stackoverflow.com/a/13480388/2050561

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