Skip to content

/commands/git/git-reset-soft-head-1

git reset --soft HEAD~1: undo the last commit, keep the changes

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · git version 2.55.0.windows.5updated 2026-10-20
tool
Git
versions
Git 2.x
os
linux, macos, windows

git reset --soft HEAD~1 removes the most recent commit from the current branch and leaves all its changes staged, ready to be committed again. Use it to fix a commit message, add a forgotten file, or split the commit.

Undo the last commit

bash
git init -q -b main repo && cd repo
echo one > a.txt && git add a.txt && git commit -qm "first"
echo two > b.txt && git add b.txt && git commit -qm "second (wrong)"
git log --oneline
git reset --soft HEAD~1
git log --oneline
git status --short

Output

6164400 second (wrong)
6a05283 first
6a05283 first
A  b.txt

b.txt is still staged (A), so git commit -m "second" recreates the commit the way you want it.

--soft vs --mixed vs --hard

ModeBranch movesIndex (staging)Working tree
--softyeskept: changes stay stagedkept
--mixed (default)yesreset: changes become unstagedkept
--hardyesresetreset: uncommitted changes are deleted

Undo the undo

The old commit is still reachable through the reflog for a while (90 days by default):

bash
git init -q -b main repo && cd repo
echo one > a.txt && git add a.txt && git commit -qm "first"
echo two > b.txt && git add b.txt && git commit -qm "second"
git reset -q --soft HEAD~1
git reset -q --soft 'HEAD@{1}'
git log --oneline

Output

5f2f41b second
6a05283 first

Sources