Restore files
high risk
git diff <file>Look at what you would losegit stash push <file>Keep a backupRestores paths from the index or a commit; --staged unstages.
| Flag | Meaning |
|---|---|
--staged --staged | Unstage |
--source --source | Restore from a commit |
--worktree --worktree | Restore the working tree (default)⚠ Discards local edits. |
git restore --staged fileUnstage · explain & risk-check →git restore fileDiscard edits · explain & risk-check →Reference text is hand-written and may be incomplete — check man git for your version. Test destructive commands on a non-production system first.