# Undo the last commit but keep the changes staged
git reset --soft HEAD~1
# Or undo and unstage the changes (working tree preserved)
git reset HEAD~1Updated Jul 17, 2026
# Undo the last commit but keep the changes staged
git reset --soft HEAD~1
# Or undo and unstage the changes (working tree preserved)
git reset HEAD~1