wt merge
Merge current branch into the target branch. Squash & rebase, fast-forward the target branch, remove the worktree.
Unlike git merge, this merges the current branch into the target branch — not the target into current. Similar to clicking "Merge pull request" on GitHub, but locally. The target defaults to the default branch.
Examples
Merge to the default branch:
wt merge
Merge to a different branch:
wt merge develop
Keep the worktree after merging:
wt merge --no-remove
Preserve commit history (no squash):
wt merge --no-squash
Create a merge commit — semi-linear history:
wt merge --no-ff
Skip committing/squashing (rebase still runs unless --no-rebase):
wt merge --no-commit
Pipeline
wt merge runs these steps:
- Commit — Pre-commit hooks run, then uncommitted changes are committed. Post-commit hooks run in background. Skipped when squashing (the default) — changes are staged during the squash step instead. With
--no-squash, this is the only commit step. - Squash — Combines all commits since target into one (like GitHub's "Squash and merge"). Use
--stageto control what gets staged:all(default),tracked, ornone. A backup ref is saved torefs/wt-backup/<branch>. With--no-squash, individual commits are preserved. - Rebase — Rebases onto target if behind. Skipped if already up-to-date. Conflicts abort immediately.
- Pre-merge hooks — Hooks run after rebase, before merge. Failures abort. See
wt hook. - Merge — Fast-forward merge to the target branch. With
--no-ff, a merge commit is created instead — semi-linear history with rebased commits plus a merge commit. Non-fast-forward merges are rejected. - Pre-remove hooks — Hooks run before removing worktree. Failures abort.
- Cleanup — Removes the worktree and branch. Use
--no-removeto keep the worktree. When already on the target branch or in the primary worktree, the worktree is preserved. - Post-remove + post-merge hooks — Run in background after cleanup.
Use --no-commit to skip committing uncommitted changes and squashing; rebase still runs by default and can rewrite commits unless --no-rebase is passed. Useful after preparing commits manually with wt step commit. Requires a clean working tree.
Local CI
For personal projects, pre-merge hooks open up the possibility of a workflow with much faster iteration — an order of magnitude more small changes instead of fewer large ones.
Historically, ensuring tests ran before merging was difficult to enforce locally. Remote CI was valuable for the process as much as the checks: it guaranteed validation happened. wt merge brings that guarantee local.
The full workflow: start an agent (one of many) on a task, work elsewhere, return when it's ready. Review the diff, run wt merge, move on. Pre-merge hooks validate before merging — if they pass, the branch goes to the default branch and the worktree cleans up.
[[pre-merge]]
test = "cargo test"
lint = "cargo clippy"See also
wt step— Run individual operations (commit, squash, rebase, push)wt remove— Remove worktrees without mergingwt switch— Navigate to other worktrees
Command reference
wt merge - Merge current branch into the target branch
Squash & rebase, fast-forward the target branch, remove the worktree.
Usage: wt merge [OPTIONS] [TARGET]
Arguments:
[TARGET]
Target branch
Defaults to default branch.
Options:
--no-squash
Skip commit squashing
--no-commit
Skip commit and squash
--no-rebase
Skip rebase (fail if not already rebased)
--no-remove
Keep worktree after merge
--no-ff
Create a merge commit (no fast-forward)
--stage <STAGE>
What to stage before committing [default: all]
Possible values:
- all: Stage everything: untracked files + unstaged tracked changes
- tracked: Stage tracked changes only (like git add -u)
- none: Stage nothing, commit only what's already in the index
-h, --help
Print help (see a summary with '-h')
Automation:
--no-hooks
Skip hooks
--format <FORMAT>
Output format
JSON prints structured result to stdout after merge completes.
Possible values:
- text: Human-readable text output
- json: JSON output
[default: text]
Global Options:
-C <path>
Working directory for this command
--config <path>
User config file path
-v, --verbose...
Verbose output (-v: info logs + hook/alias template variable & output; -vv: debug logs +
diagnostic report + trace.log/output.log under .git/wt/logs/)
-y, --yes
Skip approval prompts