← back to diagnosis

restore a deleted file

caution

Bring back a tracked file you deleted locally. If the file was never committed, it may be gone.

$ git restore <filename>

This restores the file from the last committed version. Works for tracked files only. If you already staged the deletion, unstage it first with git reset.

unstage then restore

$ git reset -- <filename>
$ git checkout -- <filename>