Three reset modes, one mental model: which of HEAD, the index, and the working tree each one moves.
git reset moves HEAD — and optionally the index and working tree — to a target commit. The three modes differ only in how far that movement ripples.
Git tracks your project through three distinct layers: HEAD (the current commit pointer), the index (what’s staged for the next commit), and the working tree (your actual files on disk).
Terminalgit reset --soft HEAD~1 # moves HEAD only git reset --mixed HEAD~1 # moves HEAD + unstages changes (default) git reset --hard HEAD~1 # moves HEAD + discards all local changes
MENTAL MODEL —soft undoes the commit. —mixed undoes the commit and the stage. —hard undoes everything.
Use --soft when you want to recommit with a different message. Use --mixed when you want to re-stage selectively. Reserve --hard for when you truly want to throw away work — it cannot be undone without the reflog.