Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
---
source: tests/integration_tests/help.rs
info:
program: wt
args:
- merge
- "--help"
env:
CLICOLOR_FORCE: "1"
COLUMNS: "500"
GIT_ALLOW_PROTOCOL: file
GIT_CONFIG_COUNT: "2"
GIT_CONFIG_GLOBAL: /nonexistent/wt/gitconfig
GIT_CONFIG_KEY_0: user.useConfigOnly
GIT_CONFIG_KEY_1: rerere.enabled
GIT_CONFIG_SYSTEM: /nonexistent/wt/gitconfig
GIT_CONFIG_VALUE_0: "true"
GIT_CONFIG_VALUE_1: "false"
LANG: C
LC_ALL: C
LLVM_PROFILE_FILE: "[LLVM_PROFILE_FILE]"
TERM: alacritty
WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
WORKTRUNK_TEST_BASH_INSTALLED: "0"
WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
WORKTRUNK_TEST_CODEX_INSTALLED: "0"
WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
WORKTRUNK_TEST_EPOCH: "1735776000"
WORKTRUNK_TEST_FISH_INSTALLED: "0"
WORKTRUNK_TEST_GEMINI_INSTALLED: "0"
WORKTRUNK_TEST_NUSHELL_ENV: "0"
WORKTRUNK_TEST_OPENCODE_INSTALLED: "0"
WORKTRUNK_TEST_PARENT_SHELL: ""
WORKTRUNK_TEST_POWERSHELL_ENV: "0"
WORKTRUNK_TEST_POWERSHELL_INSTALLED: "0"
WORKTRUNK_TEST_PROBE_TIMEOUT_MS: "60000"
WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
WORKTRUNK_TEST_ZSH_INSTALLED: "0"
---
success: true
exit_code: 0
----- stdout -----
wt merge - Merge a branch into the target branch[0m
Squash & rebase, fast-forward the target branch, remove the worktree.[0m
Usage: [1m[36mwt merge[0m [36m[OPTIONS][0m [36m[TARGET][0m
[1m[32mArguments:[0m
[36m[TARGET][0m
Target branch[0m
Defaults to default branch.[0m
[1m[32mOptions:[0m
[1m[36m-b[0m, [1m[36m--branch[0m[36m [0m[36m<BRANCH>[0m
Branch to merge (defaults to the current branch)
[1m[36m--no-squash[0m
Skip commit squashing
[1m[36m--no-commit[0m
Skip commit and squash
[1m[36m--no-rebase[0m
Skip rebase; require the target to fast-forward to the resulting tip
[1m[36m--no-remove[0m
Keep worktree after merge
[1m[36m--no-ff[0m
Create a merge commit (no fast-forward)
[1m[36m--stage[0m[36m [0m[36m<STAGE>[0m
What to stage before committing [default: all]
Possible values:
- [1m[36mall[0m: Stage everything: untracked files + unstaged tracked changes
- [1m[36mtracked[0m: Stage tracked changes only (like [1mgit add -u[0m)
- [1m[36mnone[0m: Stage nothing, commit only what's already in the index
[1m[36m-h[0m, [1m[36m--help[0m
Print help (see a summary with '-h')
[1m[32mAutomation:[0m
[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 merge completes.[0m
[default: text]
[possible values: text, json]
[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--config-set[0m[36m [0m[36m<toml>[0m
Override config with inline TOML, e.g. --config-set list.full=true (repeatable)
[1m[36m-v[0m, [1m[36m--verbose[0m[36m...[0m
Verbose output (-v: info logs + hook/alias template variables on stderr; -vv: also debug logs and raw subprocess output written to .git/wt/logs/). Set WORKTRUNK_VERBOSE=0|1|2 to apply the same level everywhere — including shell completion, which no flag can reach
[1m[36m-y[0m, [1m[36m--yes[0m
Skip approval prompts
Unlike [2mgit merge[0m, this merges a source branch into the target branch, not the target into the current branch. Similar to clicking "Merge pull request" on GitHub, but locally. The source defaults to the current branch ([2m--branch[0m names another); the target defaults to the default branch.
[1m[32mExamples[0m
Merge to the default branch:
[107m [0m [2m[0m[2m[34mwt[0m[2m merge[0m
[107m [0m [2m[0m[2m[34m◎[0m[2m Running pre-merge project:test[0m
[107m [0m [2m [0m[2m[34mcargo[0m[2m nextest run[0m
[107m [0m [2m [0m[2m[34mFinished[0m[2m `[0m[2m[34mtest[0m[2m` profile [unoptimized + debuginfo] target([0m[2m[34ms[0m[2m) [0m[2m[35min[0m[2m [0m[2m[34m0.02s[0m
[107m [0m [2m [0m[2m[34mSummary[0m[2m [ 0.002s] 2 tests run: 2 passed, 0 skipped[0m
[107m [0m [2m[0m[2m[34m◎[0m[2m Merging 1 commit to main @ a1b2c3d ([0m[2m[34mno[0m[2m commit/squash/rebase needed)[0m
[107m [0m [2m [0m[2m[34m*[0m[2m a1b2c3d feat: add hook registration[0m
[107m [0m [2m [0m[2m[34mhook.rs[0m[2m [0m[2m[36m|[0m[2m [0m[2m[34m31[0m[2m +++++++++++++++++++++++++++++++[0m
[107m [0m [2m [0m[2m[34m1[0m[2m file changed, 31 insertions([0m[2m[34m+[0m[2m)[0m
[107m [0m [2m[0m[2m[34m✓[0m[2m Merged to main ([0m[2m[34m1[0m[2m commit, 1 file, +31)[0m
[107m [0m [2m[0m[2m[34m◎[0m[2m Removing hooks worktree & [0m[2m[34mbranch[0m[2m in background ([0m[2m[34msame[0m[2m commit as main, _)[0m
[107m [0m [2m[0m[2m[34m○[0m[2m Switched to worktree for main @ ~/repo[0m
Merge to a different branch:
[107m [0m [2m[0m[2m[34mwt[0m[2m merge develop[0m
Merge another worktree's branch without leaving the current worktree:
[107m [0m [2m[0m[2m[34mwt[0m[2m merge [0m[2m[36m--branch[0m[2m feature/auth[0m
[107m [0m [2m[0m[2m[34mwt[0m[2m merge develop [0m[2m[36m--branch[0m[2m feature/auth[0m
The source branch must have a checked-out worktree. Commit, squash, rebase, and hooks use that worktree and its project configuration. Cleanup removes the source worktree; the invoking worktree stays in place. A rebase conflict is left in the source worktree to resolve or abort.
Keep the worktree after merging:
[107m [0m [2m[0m[2m[34mwt[0m[2m merge [0m[2m[36m--no-remove[0m
Preserve commit history (no squash):
[107m [0m [2m[0m[2m[34mwt[0m[2m merge [0m[2m[36m--no-squash[0m
Create a merge commit — rebased semi-linear history by default:
[107m [0m [2m[0m[2m[34mwt[0m[2m merge [0m[2m[36m--no-ff[0m
Skip committing/squashing (rebase still runs unless --no-rebase):
[107m [0m [2m[0m[2m[34mwt[0m[2m merge [0m[2m[36m--no-commit[0m
Preserve the exact clean commit graph and tip:
[107m [0m [2m[0m[2m[34mwt[0m[2m merge [0m[2m[36m--no-commit[0m[2m [0m[2m[36m--no-rebase[0m
[1m[32mPipeline[0m
[2mwt merge[0m runs these steps:
1. [1mCommit[0m — Pre-commit hooks run, then uncommitted changes are committed. Post-commit hooks run in the background. This step is skipped when squashing (the default) — changes are staged during the squash step instead. With [2m--no-squash[0m, this is the only commit step.
2. [1mSquash[0m — Combines all commits since target into one (like GitHub's "Squash and merge"). Pre-commit hooks see the staged changes, and their edits are staged into the squash commit; post-commit hooks run in the background after committing. Use [2m--stage[0m to control what gets staged: [2mall[0m (default), [2mtracked[0m, or [2mnone[0m. Working-tree changes swept into the squash are backed up first to [2mrefs/wt-backup/<branch>[0m; see [2mwt step squash[0m for recovery. With [2m--no-squash[0m, individual commits are preserved.
3. [1mRebase[0m — Rebases onto target, skipping when nothing needs replaying ([2mwt step rebase[0m gives the conditions). A conflict stops the merge with the rebase left open in the worktree, to resolve or abort. With [2m--no-rebase[0m, the graph produced by earlier commit/squash steps is preserved and the target must be able to fast-forward to its tip.
4. [1mPre-merge hooks[0m — Hooks run after rebase, before merge. Failures abort. See [2mwt hook[0m.
5. [1mMerge[0m — Fast-forward merge to the target branch ([2mwt step push[0m). With [2m--no-ff[0m, a merge commit is created instead — semi-linear history after the default rebase, while explicit [2m--no-rebase[0m preserves the graph produced by earlier steps before adding the merge commit. Non-fast-forward merges are rejected.
6. [1mPre-remove hooks[0m — Hooks run before removing worktree. Failures abort.
7. [1mCleanup[0m — Removes the worktree and branch. Use [2m--no-remove[0m to keep the worktree. When already on the target branch, in the primary worktree, locked, or containing another registered worktree, the worktree is preserved.
8. [1mPost-remove + post-merge hooks[0m — Run in background after cleanup.
Use [2m--no-commit[0m to skip committing uncommitted changes and squashing; rebase still runs by default and can rewrite commits unless [2m--no-rebase[0m is passed. Combining both flags preserves the exact source graph and requires the target to be its ancestor. Useful after preparing commits manually with [2mwt step commit[0m. Requires a clean working tree.
[2mwt merge[0m merges into the *local* target branch and never fetches.
[1m[32mLocal CI[0m
Pre-merge hooks run checks locally before merging. A failed check stops the merge:
[107m [0m [2m# .config/wt.toml[0m
[107m [0m [2m[36m[[pre-merge]][0m
[107m [0m [2mtest = [0m[2m[32m"cargo test"[0m
[107m [0m [2mlint = [0m[2m[32m"cargo clippy"[0m
[1m[32mSee also[0m
- [2mwt step[0m — Run individual operations (commit, squash, rebase, push)
- [2mwt remove[0m — Remove worktrees without merging
- [2mwt switch[0m — Navigate to other worktrees
----- stderr -----