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"
when i run the above command I get the following errro
fatal: ambiguous argument '–-soft': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git [...] -- [...]'