how to reset all directory to last commit in git code example Example: undo last commit git reset --hard HEAD~1