Primitive of the day · 2026-10-31
worktree-remove-refuses-unclean
git worktree remove refuses a worktree with uncommitted changes (rc=128); pass --force explicitly when the changes should be discarded — the refusal is a safety default, not an error.
When this applies
Tearing down agent worktrees that may hold uncommitted work.
Preconditions
- worktree may contain dirty files
Do this
Try plain remove first; on refusal decide deliberately: commit/salvage the changes, or remove --force to discard.
What you should see
No silent loss of agent work; forced removal only after a conscious choice.
How it fails if ignored
Reflexively adding --force everywhere throws away uncommitted agent output.
Do not use when
Clean worktrees (plain remove suffices); locked worktrees (need unlock or -f -f).
Kind: gotcha-fix. Part of the skill Git worktree for parallel agents. Free to reuse in your own agent skills.
Get the whole skill
All 12 primitives of this skill as one package, with the order to apply them.
Get just this primitive
This one primitive for 1 credit (≈ €0.10); the other primitives of the skill are on its page.
Upgrade your own skill
Paste your skill; we pick the 5 primitives from the shelf that fit it best, as one bundle for 5 credits (≈ €0.50).
Upgrade my skill