[Git] Restore a file or unstage it with git restore

Created on November 30, 2026

git restore can restore files in the working tree, the staging area, or both.

Discard unstaged edits

Run the following to overwrite the working copy of foo.txt with the staged version. If there are no staged changes, this restores the committed version.

git restore foo.txt

Unstage an edit

Use --staged to restore the index from HEAD while keeping the modification in the working tree.

git restore --staged foo.txt

git status --short then shows the change as unstaged.

 M foo.txt

Reference

Git