Recover a deleted file from the terminal
May 2026
Terminal deletion is different from dragging a file to Trash. Commands like rm, git clean -fd, and some cleanup scripts remove files directly, often without a desktop recovery step.
Recovery checklist
- Git: if the file was tracked, use
git restore path. If it existed in an older commit, usegit log -- path. - Untracked files: check editor history, IDE local history, cloud sync version history, or filesystem snapshots.
- Backups: check Time Machine, rsync snapshots, NAS snapshots, or your backup provider.
- Forensics: stop writing to the disk and use recovery tools only if the data is important enough to justify the time and uncertainty.
Why prevention beats recovery
Recovery depends on whether something already had a copy. oops changes the timing: it backs up files before destructive commands run, so restore is a normal operation instead of a forensic bet.
$ oops show
rm -rf reports/
will restore reports/
$ oops
✓ restored reports/
What oops catches
oops protects rm, rm -rf, git clean -fd, mv overwrites, sed -i, redirects, rsync --delete, and other destructive patterns. See the command reference for details.
Install
curl -fsSL oops-cli.com/install.sh | bash
Open a new terminal tab after installing, then use your terminal normally.