wt merge
Merge the current branch into the target branch and clean up. Handles the full workflow: commit uncommitted changes, squash commits, rebase, run hooks, push to target, and remove the worktree.
When already on the target branch or in the main worktree, the worktree is preserved automatically.
Examples
Basic merge to main:
Merge to a different branch:
Keep the worktree after merging:
Preserve commit history (no squash):
Skip git operations, only run hooks and push:
Pipeline
wt merge runs these steps:
- Squash — Stages uncommitted changes, then 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, uncommitted changes are committed separately and individual commits are preserved. - Rebase — Rebases onto target if behind. Skipped if already up-to-date. Conflicts abort immediately.
- Pre-merge hooks — Project commands run after rebase, before merge. Failures abort. See Hooks.
- Merge — Fast-forward merge to the target branch. Non-fast-forward merges are rejected.
- Cleanup — Removes the worktree and branch. Use
--no-removeto keep the worktree. - Post-merge hooks — Project commands run after cleanup. Failures are logged but don't abort.
Use --no-commit to skip all git operations (steps 1-2) and only run hooks and merge. Useful after preparing commits manually with wt step. Requires a clean working tree.
See also
- wt step — Run individual merge steps (commit, squash, rebase, push)
- wt remove — Remove worktrees without merging
- wt switch — Navigate to other worktrees
Command reference
wt merge - Merge worktree into target branch
Usage: wt merge [OPTIONS] [TARGET]
Arguments:
[TARGET]
Target branch
Defaults to default branch.
Options:
--no-squash
Skip commit squashing
--no-commit
Skip commit, squash, and rebase
--no-remove
Keep worktree after merge
--no-verify
Skip all project hooks
-f, --force
Skip approval prompts
--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')
Global Options:
-C <path>
Working directory for this command
--config <path>
User config file path
-v, --verbose
Show commands and debug info