Git & GitHub Interview Question #54

What is the difference between git restore and git reset?

Undo & Recovery, Tags, Forks, Pull Requests & Code Review Mid-Level Intermediate

Quick Interview Answer

git restore primarily works with file content in the working tree and index. git reset can move the current branch reference and can also reset the index and working tree depending on its mode.

Detailed Explanation

git restore primarily works with file content in the working tree and index. git reset can move the current branch reference and can also reset the index and working tree depending on its mode.

For a beginner-friendly workflow, git restore is often clearer for discarding file changes or unstaging files, while reset is used when changing commit or index state. The exact command should match the intended scope.

Code Example

# Unstage a file
git restore --staged appsettings.json

# Move the branch back one commit
git reset --soft HEAD~1