Restore a file in the working tree from the index.
Section: Restore Basics
Discard unstaged changes in a file
bash
bash
git restore path/to/fileExplanation
Modern command for throwing away local unstaged edits to a path.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Restore Basics
Unstage a file with restore
Restore the index entry for a path from HEAD.
Restore a file from another commit
Copy file contents from a specific commit into the working tree.
Interactively restore hunks
Select portions of a file to restore interactively.
Restore both index and working tree from another commit
Reset a file to another revision in both staging area and working tree.
Undo last commit but keep everything staged
Move HEAD back one commit while preserving index and working tree.
Revert a single commit
Create a new commit that reverses an earlier commit.