Skip to main content

Module restore

Module restore 

Source
Expand description

mkit restore [--staged] [--worktree] [--source <rev>] [-f] <path>... — discard worktree changes for path(s), or unstage them.

Mirrors the everyday halves of git restore:

  • default (no --staged) — restore the worktree file(s) for each path from the index (the staged content), discarding uncommitted worktree edits. Reuses the #176 “don’t clobber user work” spirit: a worktree file whose content diverges from the staged blob is refused without -f/--force, so an accidental restore never silently eats an un-staged edit.
  • --staged — restore the index entry for each path from HEAD (i.e. unstage it), leaving the worktree file exactly as it is. This touches only .mkit/index, never the worktree, so it needs no dirty guard and no --force.
  • --staged --worktree (both) — unstage AND discard the worktree edit in one step (worktree restored from HEAD since the staged entry is being reset to HEAD too); the dirty guard still applies to the worktree half.
  • --source <rev> — take the restored content from <rev>’s tree (resolved via the shared revspec resolver) instead of the index/HEAD default.

A path that names a directory restores every tracked entry at or below it. Restoring the worktree never removes extra files; it only rewrites the named tracked paths from the source tree.

Functions§

run