What does git reset --soft/--mixed/--hard do?
⚡
Quick Answer
All move the branch pointer; --soft keeps changes staged, --mixed (default) unstages them, --hard discards them entirely.
Detailed Answer
reset repoints HEAD to a commit. --soft leaves your index and working tree intact (changes staged). --mixed resets the index but keeps the working tree. --hard also resets the working tree, permanently discarding uncommitted work — the dangerous one. Use git reflog to recover if you reset by mistake.
Code Example
git reset --soft HEAD~1 # undo last commit, keep changes staged
💡
Interview Tip
Know reflog as the safety net after a bad reset.
gitresetrecovery