Undo a “public” change

git revert <SHA>

Fix the last commit message

git commit --amend or git commit --amend -m "Fixes bug #42"

Undo “local” changes

git checkout -- <bad filename>

Reset “local” changes

git reset <last good SHA> ;or git reset --hard <last good SHA>

Redo after undo “local”

git reflog and git reset ;or git checkout

Mass undo/redo

git rebase -i <earlier SHA>

Fix an earlier commit

git commit --squash <SHA of the earlier commit> ;and git rebase --autosquash -i <even earlier SHA>

Stop tracking a tracked file

git rm --cached application.log

Link