Interview Q&A / Git & GitHub

IntermediateQuick answer1 min readUpdated 3 Oct 2026

When would you use git restore instead of git reset?

SHORT ANSWER

Use git restore to change files, either discarding edits or unstaging a path. Use git reset to move the branch pointer to another commit. Restore never moves your branch.

Explain it simply

Both can unstage a file, which causes confusion. The real difference is the target. git reset is about the branch: move it to another commit. git restore is about files: bring them back to a known state.

If you only want to fix one file, git restore --staged file unstages it and git restore file discards its edits. If you want to remove or rework a commit, that is reset or revert. Restore is more predictable for beginners, since it cannot accidentally rewind commits.

Example

bash
git restore --staged index.html   # unstage one file
git restore index.html            # discard its edits
git reset --soft HEAD~1           # rewind a commit

What to say in the interview

"restore works on files in the working tree or index, and reset moves the branch tip, optionally changing the index and working tree. For fixing a single file I use restore, and for rewriting commits I use reset or revert."

#git#restore#reset

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.