git reset --hard HEAD~N- To undo last commit and changes.N stands for how far you would like to undo your changes. For undo last changes N=1 Let's talk about below use case where C is current HEAD while F is a state of files.
(F)
A-B-C
↑
master
If you like to undo commit C. You do this:
git reset --hard HEAD~1
The result is:
(F)
A-B
↑
master