Interview Questions: Undoing
Reset, revert and more.
Undoing things is where people get nervous, and interviewers know it. Calm, correct answers here really stand out.

- Undoing makes people nervous
- Interviewers know it
- Calm answers stand out
Reset versus revert?
Question seven. What's the difference between git reset and git revert? Reset moves your branch back to an earlier commit, removing the later ones from the branch. It rewrites history, so it's for local commits only. Revert creates a new commit that undoes an earlier one. History is kept, so it's safe for shared branches.
git reset
- Moves the branch back
- Rewrites history
- Local commits only
git revert
- Adds an undo commit
- Keeps history
- Safe when shared
Soft, mixed and hard?
Question eight. What do soft, mixed and hard mean in git reset? They all move the branch. Soft keeps your changes staged. Mixed, the default, keeps them, but unstaged. Hard throws them away. Mention that hard can lose uncommitted work.
| Mode | Your changes |
|---|---|
| --soft | kept, staged |
| --mixed (default) | kept, unstaged |
| --hard | discarded |
How do you recover a lost commit?
Question nine. How do you recover a commit after a bad reset? Use git reflog. It lists every position head has been at. Find the lost commit's hash, then reset back to it, or create a branch at it. Mention that the reflog is local, and kept for around ninety days.
Summary
Reset versus revert, the three reset modes, and the reflog. Next, a final round of questions about teams and good practice.
Key takeaways- reset: local, rewrites
- revert: shared, safe
- reflog: the safety net