Restore a deleted file in Git
Safe: nothing is lost
Short answer
If the deletion isn't committed, run git restore <file>: Git puts back the last committed version.
The commands, one by one
- 1
git status -sThe file shows
D: deleted on disk, still in Git. - 2
git restore scones.txtWrites the last committed version of the file back to disk.
For your own repository: If you also staged the deletion (D in the first column), run git restore --staged scones.txt first.