Remove a worktree
import { Aside } from “@astrojs/starlight/components”;
wos worktree remove removes the current secondary Git worktree through the
daemon. It is the only command that combines WorktreeOS state cleanup with
git worktree remove.
What it does
Section titled “What it does”In order:
- Tears down WorktreeOS-deployed resources for the current worktree (containers, port assignments, registered tunnel routes).
- Deletes persistent WorktreeOS session artifacts for the current worktree
under
<wos-home>/sessions/<session-name>. - Invokes
git worktree removefor the current worktree path.
Contrast this with wos down, which keeps the
session, the generated Compose file, and the worktree itself.
# Remove the current secondary worktree if it is clean and linked.wos worktree remove
# Force removal of a dirty or unlinked worktree# (passes --force to git worktree remove).wos worktree remove --forceConstraints
Section titled “Constraints”-
The source/primary worktree cannot be removed through WorktreeOS. Run the command from inside a secondary worktree, or target one with
--cwd:Terminal window wos --cwd /var/www/feature-login worktree remove -
--forceis forwarded togit worktree remove. It removes worktrees with uncommitted changes or worktrees Git considers unlinked. Do not use it casually. -
Removal goes through the daemon, so the daemon must be reachable. If it is unhealthy, fix that first (see Daemon errors).
Safe removal flow
Section titled “Safe removal flow”- Confirm the worktree should be deleted, including any uncommitted work.
- Run
wos statusto see what is currently deployed. - Optionally run
wos downfor a clean, observable Compose shutdown first. - Check the worktree’s Git status to decide whether
--forceis required; prefer non---forceremoval when the worktree is clean. - Run
wos --cwd <secondary-path> worktree remove [--force]and report the outcome.