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→