git reset --soft vs --mixed vs --hard Explained

git reset moves the current branch pointer to a different commit, and its mode controls what happens to the changes in between.

Published September 29, 2026

git reset moves the branch pointer to another commit. --soft keeps your changes staged, --mixed (default) keeps them unstaged, and --hard discards them completely.

How it works

Think of three areas: commit history, staging area and working tree. Soft changes only the first, mixed the first two, hard all three.

reset rewrites history; use revert for commits that are already shared.

Try it

git reset --soft HEAD~1
commit undone, changes staged
git reset --mixed HEAD~1
changes unstaged
git reset --hard HEAD~1
changes gone

Practical examples

Undo a commit, keep work staged

git reset --soft HEAD~1

Unstage everything

git reset

Throw everything away

git reset --hard origin/main

Recover from a mistake

git reflog
git reset --hard HEAD@{1}

Common mistakes

  • Using --hard with uncommitted work you need.
  • Resetting shared commits and forcing a push.
  • Confusing reset with revert.

Key takeaways

  • soft = keep staged, mixed = keep unstaged, hard = discard.
  • Only on unshared commits.
  • reflog is your safety net.

FAQ

reset vs revert?

reset rewrites history; revert adds an inverse commit.

What is HEAD~1?

The commit before HEAD.

More Git articles