AZ.dev

Undo the last commit but keep the changes

| git: 2.0+

Reset the last commit while keeping all changes staged and ready to re-commit.

git reset --soft HEAD~1

Your files stay exactly as they were. The commit is gone, but the changes are staged (in the index), ready for a new commit.

When to use this

The three reset modes

Mode Commit Staging area Working directory
--soft Undone Kept Kept
--mixed (default) Undone Cleared Kept
--hard Undone Cleared Cleared

Use --soft when you want to redo the commit. Use --mixed when you want to restage selectively. Never use --hard unless you want to discard changes entirely.

Gotchas

reset undo commit soft

Was this helpful?