← Back to browse
Undo the last commit (keep changes)
Undo a git commit while keeping your changes staged.
Bash5 linesUpdated Jul 17, 2026
Bash
# 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