Undo commit

Undo latest commit and drop all changes. Warning - any other changes files will also be reset.

$ git reset --hard HEAD~

Safer:

[[ -z $(git status --porcelain) ]] && git reset --hard HEAD~ || echo 'Unstaged changes!'

Then run:

$ git stash --include-untracked

Then try again.

Restore local to match remote

This will get rid of any unpushed commits.

$ git checkout origin/master .