Undo Local Git Commit

I accidentally committed the wrong files to Git, but didn’t push the commit to the server yet.

How do I undo those commits from the local repository?

$ git commit -m "Something terribly misguided" # (0: Your Accident)
$ git reset HEAD~                              # (1)
[ edit files as necessary ]                    # (2)
$ git add .                                    # (3)
$ git commit -c ORIG_HEAD                      # (4)

source: https://stackoverflow.com/a/927386