Undo 'git add'
Unstage a file but keep changes in working directory.
git reset HEAD <file>
Undo local changes (Discard file)
Revert file to state in last commit.
git checkout -- <file>
Undo last commit (Keep changes)
Soft reset moves HEAD back one step but keeps changes staged.
git reset --soft HEAD~1
Undo last commit (Discard changes)
Hard reset moves HEAD back and deletes changes. Dangerous.
git reset --hard HEAD~1
Change last commit message
git commit --amend -m "New message"