git restore

Restore files

high risk

interactive breakdown — edit the command and press Explain
$ 
⚠ Risks & cautions
Safer / dry-run alternatives
git diff <file>Look at what you would lose
git stash push <file>Keep a backup
What it does

Restores paths from the index or a commit; --staged unstages.

Common flags
FlagMeaning
--staged --stagedUnstage
--source --sourceRestore from a commit
--worktree --worktreeRestore the working tree (default)⚠ Discards local edits.
Examples
git restore --staged fileUnstage · explain & risk-check →
git restore fileDiscard edits · explain & risk-check →
Related
git checkout git stash
Open the full explainer →More in Git

Reference text is hand-written and may be incomplete — check man git for your version. Test destructive commands on a non-production system first.