Git Reset: Soft, Hard, and Mixed Modes Explained

Understand the difference between git reset --soft, --mixed, and --hard. Learn when to use each mode to undo commits safely in Git.

git reset --soft HEAD~1

Detailed Explanation

What Does git reset Do?

git reset moves the current branch pointer to a different commit. The three modes — --soft, --mixed, and --hard — control what happens to the staging area (index) and working directory.

The Three Modes

Mode HEAD Staging Area Working Directory
--soft Moves Unchanged Unchanged
--mixed (default) Moves Reset Unchanged
--hard Moves Reset Reset

--soft: Undo the Commit, Keep Everything Staged

git reset --soft HEAD~1

This is perfect when you want to re-do a commit — the changes remain staged and ready to commit again with a different message or combined with other changes.

--mixed: Undo the Commit, Unstage Changes

git reset HEAD~1
# or explicitly:
git reset --mixed HEAD~1

Changes are preserved in your working directory but are no longer staged. Use this when you want to re-organize which files go into which commit.

--hard: Undo Everything

git reset --hard HEAD~1

This permanently discards changes. The commit, staging area, and working directory are all reverted. Use this only when you are certain you want to throw away work.

Safety Tips

  • Always check git reflog before panicking — even --hard resets can be undone if you act before garbage collection.
  • Prefer --soft or --mixed unless you truly want to destroy uncommitted changes.
  • Never use git reset on commits that have been pushed to a shared branch — use git revert instead, which creates a new commit that undoes the changes.

Use Case

A developer committed with the wrong message and wants to redo the commit. They use git reset --soft HEAD~1 to undo the commit while keeping all changes staged.

Try It — Git Command Builder

Open full tool