oops is in beta. Report any issues on GitHub.

How to undo rm -rf

May 2026

rm -rf is dangerous because it recursively removes files without asking, and -f suppresses many safety prompts. Once it runs, the terminal does not keep an undo stack.

First, check what was protected

If the deleted directory was in git, committed files can usually be restored with git restore path/. Uncommitted changes and untracked files are the hard part. Look for editor local history, snapshots, Time Machine, filesystem snapshots, or cloud backup history.

Do not keep writing large amounts of new data to the disk if you plan to try forensic recovery. Even then, results are not dependable on modern SSDs.

Preventing recursive delete damage

oops catches rm -rf before it runs and backs up the target tree into ~/.oops/trash/. Then the original command still runs normally, so scripts and muscle memory do not change.

$ rm -rf src/fixtures $ oops restore --plan will restore src/fixtures/ $ oops ✓ restored src/fixtures/

Use a plan before restoring

For large trees, run oops restore --plan or oops undo --dry-run. It shows what would be restored, conflict behavior, and whether anything would be backed up before overwrite.

Install

curl -fsSL oops-cli.com/install.sh | bash

For single-file deletes, see how to undo rm. For AI tools that may run recursive deletes, see AI agent rm -rf protection.