wt remove
Remove worktree; delete branch if merged. Defaults to the current worktree.
Examples
Remove current worktree:
wt remove Remove specific worktrees / branches:
wt remove feature-branch wt remove old-feature another-branch Keep the branch:
wt remove --no-delete-branch feature-branch Force-delete an unmerged branch:
wt remove -D experimentalBranch cleanup
By default, branches are deleted when merging them would add nothing. This works with squash-merge and rebase workflows where commit history differs but file changes match.
Worktrunk checks five conditions (in order of cost):
- Same commit — Branch HEAD equals the default branch. Shows
_inwt list. - Ancestor — Branch is in target's history (fast-forward or rebase case). Shows
⊂. - No added changes — Three-dot diff (
target...branch) is empty. Shows⊂. - Trees match — Branch tree SHA equals target tree SHA. Shows
⊂. - Merge adds nothing — Simulated merge produces the same tree as target. Handles squash-merged branches where target has advanced. Shows
⊂.
The 'same commit' check uses the local default branch; for other checks, 'target' means the default branch, or its upstream (e.g., origin/main) when strictly ahead.
Branches showing _ or ⊂ are dimmed as safe to delete.
Force flags
Worktrunk has two force flags for different situations:
| Flag | Scope | When to use |
|---|---|---|
--force (-f) | Worktree | Worktree has untracked files (build artifacts, IDE config) |
--force-delete (-D) | Branch | Branch has unmerged commits |
wt remove feature --force # Remove worktree with untracked files wt remove feature -D # Delete unmerged branch wt remove feature --force -D # Both Without --force, removal fails if the worktree contains untracked files. Without -D, removal keeps branches with unmerged changes. Use --no-delete-branch to keep the branch regardless of merge status.
Background removal
Removal runs in the background by default (returns immediately). Logs are written to .git/wt/logs/{branch}-remove.log. Use --foreground to run in the foreground.
Hooks
pre-remove hooks run before the worktree is deleted (with access to worktree files). post-remove hooks run after removal. See wt hook for configuration.
See also
Command reference
wt remove - Remove worktree; delete branch if merged Defaults to the current worktree. Usage: wt remove [OPTIONS] [BRANCHES]... Arguments: [BRANCHES]... Branch name [default: current] Options: --no-delete-branch Keep branch after removal -D, --force-delete Delete unmerged branches --foreground Run removal in foreground (block until complete) -f, --force Force worktree removal Remove worktrees even if they contain untracked files (like build artifacts). Without this flag, removal fails if untracked files exist. -h, --help Print help (see a summary with '-h') Automation: -y, --yes Skip approval prompts --no-verify Skip hooks Global Options: -C <path> Working directory for this command --config <path> User config file path -v, --verbose... Verbose output (-v: hooks, templates; -vv: debug report)