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:

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

Skip git operations, only run hooks and push:

wt merge --no-commit

Pipeline

wt merge runs these steps:

  1. Squash — Stages uncommitted changes, then combines all commits since target into one (like GitHub's "Squash and merge"). Use --stage to control what gets staged: all (default), tracked, or none. A backup ref is saved to refs/wt-backup/<branch>. With --no-squash, uncommitted changes are committed separately and individual commits are preserved.
  2. Rebase — Rebases onto target if behind. Skipped if already up-to-date. Conflicts abort immediately.
  3. Pre-merge hooks — Project commands run after rebase, before merge. Failures abort. See Hooks.
  4. Merge — Fast-forward merge to the target branch. Non-fast-forward merges are rejected.
  5. Cleanup — Removes the worktree and branch. Use --no-remove to keep the worktree.
  6. 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


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