QA
Beginner LevelGit & GitHub

How does git restore discard uncommitted local changes?

❓ Interview Prompt: Explain git restore syntax for discarding uncommitted working directory edits and un-staging staged files.

git restore <file> discards uncommitted changes in your working directory, reverting the file to its last committed state. git restore --staged <file> removes the file from the Staging Area Index while preserving local edits.

Code Implementation Example

bash
git restore src/app.js
git restore --staged src/config.js
git restore .
💡Discarding local edits and un-staging files using modern git restore.
🎯 Interview Key Takeaway

Use git restore <file> to discard local uncommitted file modifications, and git restore --staged <file> to unstage files.

#git restore#Discard Changes#Beginner
Back to all Git & GitHub Questions→

More Git & GitHub Interview Questions

Beginner LevelGit & GitHub

Compare git rebase versus git merge and explain how git bisect finds regressions.

Beginner LevelGit & GitHub

What is the difference between git init and git clone?

Beginner LevelGit & GitHub

What are the Three Trees in Git (Working Directory, Staging Area / Index, Commit History)?