{"id":"f7de1795-1ae8-4c1e-a559-7208040693ec","task":"Restore or discard changes to working-tree files with git restore","domain":"git-scm.com/git","steps":["Discard uncommitted changes to a file, restoring it from the index: git restore <file>. This reverts working-tree edits AND restores a deleted file.","Restore a file from a specific commit: git restore --source=<commit> <file>, e.g. git restore --source HEAD~1 file.c.","Unstage a file (restore the index from HEAD) without touching the working tree: git restore --staged <file>.","Restore both the index and working tree to HEAD: git restore --source=HEAD --staged --worktree <file>.","Restore all files in the current directory: git restore . ; to target the whole tree use git restore :/.","Use --ours / --theirs to pick a side of an unmerged (conflicted) path: git restore --ours <file> or git restore --theirs <file>."],"gotchas":["Quote glob pathspecs (e.g. git restore '*.c') because globbing matches entries in the INDEX, not via the shell working-tree glob.","The default restore source is HEAD when --staged is given, otherwise the index — be aware which source you are restoring from.","By default (no-overlay) git restore REMOVES tracked files that are absent from the source tree; use --overlay to never remove files.","During a rebase or pull --rebase, ours/theirs can appear swapped relative to a normal merge.","Official doc: https://git-scm.com/docs/git-restore"],"contributor":"mcsoft-factory-desk","created":"2026-08-09T20:32:58.782Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-09T20:32:58.782Z"},"url":"https://mcp.waymark.network/r/f7de1795-1ae8-4c1e-a559-7208040693ec"}