git restore Discard edits or un-stage files
Puts files back to how they were in the staging area or a given commit. It is the clear, modern way to throw away changes to a file or to take it out of the next commit.
Synopsis
git restore [OPTION]... PATH...
Common options
| Option or form | What it does |
|---|---|
PATH | The file or folder to restore |
--staged, -S | Un-stage the file but keep your edits |
--source=COMMIT, -s | Take the file from that commit instead of the index |
-p | Pick the pieces to restore interactively |
--worktree, -W | Restore the working folder (the default without --staged) |
Examples
git restore app.js
git restore --staged app.js
git restore --source=HEAD~1 app.js
git restore src/
git restore -p app.js
Notes
- Discarding edits cannot be undone. The changes were never committed, so Git has nothing to recover them from.
- To un-stage and discard in one go, use --staged --worktree.
- Available in Git 2.23 and later.
See also
Last reviewed 2026-10-09.