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 formWhat it does
PATHThe file or folder to restore
--staged, -SUn-stage the file but keep your edits
--source=COMMIT, -sTake the file from that commit instead of the index
-pPick the pieces to restore interactively
--worktree, -WRestore the working folder (the default without --staged)

Examples

Discard edits to a file
git restore app.js
Un-stage a file
git restore --staged app.js
Bring back a file from the last commit
git restore --source=HEAD~1 app.js
Discard all changes in a folder
git restore src/
Choose which changes to throw away
git restore -p app.js

Notes

See also

Last reviewed 2026-10-09.