how to undo the last commit in git from local code example Example: undo last commit $ git reset --hard HEAD~1