grit restore [--staged] [--worktree] [--source=<rev>] -- <path>…
Description
Discards local changes for tracked paths you name. By default, grit restore resets the working tree to match the index (the same idea as unstaging worktree edits while keeping the index as-is).
--stagedresets the index fromHEAD(or from--sourcewhen you pass it). On an unborn branch, staged paths are removed from the index.--worktreeresets the working tree. When you omit both flags, only the worktree is restored.--source=<rev>reads content from a commit or tree instead of the usual default (HEADfor--staged, the index for the worktree).- Paths that are missing in the source are removed from the target. Untracked files are never touched.
Options
| Option | Description |
|---|---|
<path>… |
One or more pathspecs (required). |
-S, --staged |
Restore the index. |
-W, --worktree |
Restore the working tree. |
--source |
Commit or tree to restore from. |
JSON output
Pass --json for scripting:
| Field | Type | Meaning |
|---|---|---|
restored |
array of strings | Paths created or updated. |
removed |
array of strings | Paths removed because the source had no entry. |
Markdown output
Pass --markdown for agent-friendly bullet lists of restored and removed paths.