Git: Undo the last commit
A short, tested Git example for undo the last commit. Copy it and adjust the names and paths for your project.
Git
git reset --soft HEAD~1 # undo commit, keep changes staged
git reset HEAD~1 # undo commit, keep changes unstaged
git reset --hard HEAD~1 # undo commit AND discard changes (destructive)
git revert HEAD # new commit that undoes it (safe for shared branches)Find it in Zest
Search for “git undo the last commit” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.