What it does
zm.discard
Throw away uncommitted changes, reverting paths toward their last
commit. Behaviour is context-sensitive per path, matching the shell
zm discard:
- Staged path → unstaged (safe; the working edits are preserved, the path just leaves the staging area).
- Dirty path (unstaged working edits) → content reverted to the
last commit. One shot; the discarded bytes are snapshotted to trash
first, so it is recoverable with
zm.restore(<handle>). - Deleted path → comes back as its committed version. Nothing was thrown away, so nothing lands in trash for it.
- Folder → every file beneath it is taken back with it in one step; the files are what the result reports.
- Neither → skipped.
Pass one path, an array, or . / -A / --all to process every
staged + dirty path at once. Returns { unstaged, reverted, skipped }
path lists. Every call returns a ZmToolResult; check .ok.
To fully reset a path that is both staged and dirty, run it twice: the first call unstages, the second reverts the working edits.
Discussion
Scoped to this part · feeds back into the world's score.
Sign in to post.sign in
No comments yet. Be the first.