---
source: tests/integration_tests/help.rs
info:
program: wt
args:
- remove
- "--help"
env:
CLICOLOR_FORCE: "1"
COLUMNS: "500"
GIT_EDITOR: ""
LANG: C
LC_ALL: C
NO_COLOR: ""
PSModulePath: ""
RUST_LOG: warn
SHELL: ""
TERM: alacritty
WORKTRUNK_APPROVALS_PATH: /nonexistent/test/approvals.toml
WORKTRUNK_CONFIG_PATH: /nonexistent/test/config.toml
WORKTRUNK_SYSTEM_CONFIG_PATH: /etc/xdg/worktrunk/config.toml
WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
WORKTRUNK_TEST_EPOCH: "1735776000"
WORKTRUNK_TEST_NUSHELL_ENV: "0"
WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
---
success: true
exit_code: 0
----- stdout -----
wt remove - Remove worktree; delete branch if merged[0m
Defaults to the current worktree.[0m
Usage: [1m[36mwt remove[0m [36m[OPTIONS][0m [36m[BRANCHES]...[0m
[1m[32mArguments:[0m
[36m[BRANCHES]...[0m
Branch name [default: current]
[1m[32mOptions:[0m
[1m[36m--no-delete-branch[0m
Keep branch after removal
[1m[36m-D[0m, [1m[36m--force-delete[0m
Delete unmerged branches
[1m[36m--foreground[0m
Run removal in foreground (block until complete)
[1m[36m-f[0m, [1m[36m--force[0m
Force worktree removal[0m
Remove worktrees even if they contain untracked files (like build artifacts). Without this flag, removal fails if untracked files exist.[0m
[1m[36m-h[0m, [1m[36m--help[0m
Print help (see a summary with '-h')
[1m[32mAutomation:[0m
[1m[36m-y[0m, [1m[36m--yes[0m
Skip approval prompts
[1m[36m--no-hooks[0m
Skip hooks
[1m[36m--format[0m[36m [0m[36m<FORMAT>[0m
Output format[0m
JSON prints structured result to stdout after removal completes.[0m
Possible values:
- [1m[36mtext[0m: Human-readable text output
- [1m[36mjson[0m: JSON output
[default: text]
[1m[32mGlobal Options:[0m
[1m[36m-C[0m[36m [0m[36m<path>[0m
Working directory for this command
[1m[36m--config[0m[36m [0m[36m<path>[0m
User config file path
[1m[36m-v[0m, [1m[36m--verbose[0m[36m...[0m
Verbose output (-v: info logs + hook/template output; -vv: debug logs + diagnostic report + trace.log/output.log under .git/wt/logs/)
[1m[32mExamples[0m
Remove current worktree:
[107m [0m [2m[0m[2m[34mwt[0m[2m remove[0m
Remove specific worktrees / branches:
[107m [0m [2m[0m[2m[34mwt[0m[2m remove feature-branch[0m
[107m [0m [2m[0m[2m[34mwt[0m[2m remove old-feature another-branch[0m
Keep the branch:
[107m [0m [2m[0m[2m[34mwt[0m[2m remove [0m[2m[36m--no-delete-branch[0m[2m feature-branch[0m
Force-delete an unmerged branch:
[107m [0m [2m[0m[2m[34mwt[0m[2m remove [0m[2m[36m-D[0m[2m experimental[0m
[1m[32mBranch cleanup[0m
By default, branches are deleted when they would add no changes to the default branch if merged. This works with both unchanged git histories, and squash-merge or rebase workflows where commit history differs but file changes match.
Worktrunk checks six conditions (in order of cost):
1. [1mSame commit[0m — Branch HEAD equals the default branch. Shows [2m_[0m in [2mwt list[0m.
2. [1mAncestor[0m — Branch is in target's history (fast-forward or rebase case). Shows [2m⊂[0m.
3. [1mNo added changes[0m — Three-dot diff ([2mtarget...branch[0m) is empty. Shows [2m⊂[0m.
4. [1mTrees match[0m — Branch tree SHA equals target tree SHA. Shows [2m⊂[0m.
5. [1mMerge adds nothing[0m — Simulated merge produces the same tree as target. Handles squash-merged branches where target has advanced with changes to different files. Shows [2m⊂[0m.
6. [1mPatch-id match[0m — Branch's entire diff matches a single squash-merge commit on target. Fallback for when the simulated merge conflicts because target later modified the same files the branch touched. Shows [2m⊂[0m.
The 'same commit' check uses the local default branch; for other checks, 'target' means the default branch, or its upstream (e.g., [2morigin/main[0m) when strictly ahead.
Branches matching these conditions and with empty working trees are dimmed in [2mwt list[0m as safe to delete.
[1m[32mForce flags[0m
Worktrunk has two force flags for different situations:
Flag Scope When to use
─────────────────── ──────── ────────────────────────────
[2m--force[0m ([2m-f[0m) Worktree Worktree has untracked files
[2m--force-delete[0m ([2m-D[0m) Branch Branch has unmerged commits
[107m [0m [2m[0m[2m[34mwt[0m[2m remove feature [0m[2m[36m--force[0m[2m # Remove worktree with untracked files[0m[2m[0m
[107m [0m [2m[0m[2m[34mwt[0m[2m remove feature [0m[2m[36m-D[0m[2m # Delete unmerged branch[0m[2m[0m
[107m [0m [2m[0m[2m[34mwt[0m[2m remove feature [0m[2m[36m--force[0m[2m [0m[2m[36m-D[0m[2m # Both[0m[2m[0m
Without [2m--force[0m, removal fails if the worktree contains untracked files. Without [2m--force-delete[0m, removal keeps branches with unmerged changes. Use [2m--no-delete-branch[0m to keep the branch regardless of merge status.
[1m[32mBackground removal[0m
Removal runs in the background by default — the command returns immediately. The worktree is renamed into [2m.git/wt/trash/[0m (instant same-filesystem rename), git metadata is pruned, the branch is deleted, and a detached [2mrm -rf[0m finishes cleanup. Cross-filesystem worktrees fall back to [2mgit worktree remove[0m. Logs: [2m.git/wt/logs/{branch}/internal/remove.log[0m. Use [2m--foreground[0m to run in the foreground.
After each [2mwt remove[0m, entries in [2m.git/wt/trash/[0m older than 24 hours are swept by a detached [2mrm -rf[0m — eventual cleanup for directories orphaned when a previous background removal was interrupted (SIGKILL, reboot, disk full).
[1m[32mHooks[0m
[2mpre-remove[0m hooks run before the worktree is deleted (with access to worktree files). [2mpost-remove[0m hooks run after removal. See [2mwt hook[0m for configuration.
[1m[32mDetached HEAD worktrees[0m
Detached worktrees have no branch name. Pass the worktree path instead: [2mwt remove /path/to/worktree[0m.
[1m[32mSee also[0m
- [2mwt merge[0m — Remove worktree after merging
- [2mwt list[0m — View all worktrees
----- stderr -----