Explain the difference between --soft, --mixed, and --hard resets.
Short answer: Reset Type What It Does Example Scenario -soft Moves HEAD to a previous commit but keeps your changes staged You committed too early and just want to edit the message or add more changes.
Explain a bit more
-mixed (default) Moves HEAD and unstages files but keeps your changes in the working directory You want to redo your git add selections. -hard Completely resets everything — deletes all local changes You want to discard all work and return to a clean state. Example: git reset --soft HEAD~1 # undo last commit, keep staged git reset --mixed HEAD~1 # undo last commit, unstage files git reset --hard HEAD~1 # undo last commit and delete changes
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png