Interview Q&A / Git & GitHub

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What is the difference between git reset --soft, --mixed and --hard?

SHORT ANSWER

All three move the branch to another commit. --soft keeps your changes staged, --mixed (the default) keeps them but unstaged, and --hard throws them away completely.

Explain it simply

Say you made three commits and want to undo the last one. Reset moves the branch back; the three modes decide what happens to the work from that commit.

--soft leaves the changes staged, ready to commit again, handy for combining commits. --mixed unstages them but leaves the files edited. --hard resets files too, deleting uncommitted work, so use it carefully. Think of three drawers: soft keeps the papers on the desk in the outgoing tray, mixed puts them on the desk, hard puts them in the shredder.

Example

bash
git reset --soft HEAD~1    # undo commit, keep changes staged
git reset HEAD~1           # --mixed: keep changes, unstaged
git reset --hard HEAD~1    # undo commit and delete the changes

What to say in the interview

"All three move the current branch to the target commit. Soft keeps changes staged, mixed unstages them but keeps the files, and hard resets the working directory too and loses uncommitted changes. I reach for --hard only when I really want to discard work."

Common mistakes

  • Running --hard with uncommitted changes you still need.

#git#reset#undo

Related questions

Practise more Git & GitHub questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Git & GitHub quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.