Skip to content

The merge command performs a safe, two-phase merge of a worktree's feature branch back into its base branch with conflict guard -- file-level overlap detection that warns before merge when two branches touch the same files. After a successful merge, it automatically cleans up the worktree, tmux session, and status tracking.

Usage

bash
owt merge <name> [OPTIONS]

Alias: owt m

Arguments

ArgumentDescription
nameWorktree name or branch name to merge

Options

OptionDescription
--base <branch>Target base branch (default: auto-detected)
--keepKeep the worktree after merging (skip auto-cleanup)
-y, --yesSkip confirmation prompt

Two-Phase Merge

Open Orchestrator uses a two-phase merge strategy to catch conflicts early and ensure clean merges.

Before either phase begins, the main repository is auto-stashed if dirty (including untracked files with -u), and gitignored files are cleaned (git clean -fdX) to prevent checkout failures from build artifacts or generated files like .harness/ directories. The stash is restored after the merge completes.

Phase 1: Merge Base into Feature

base (main):     A---B---C---D
                      \
feature:               E---F---G

First, the base branch is merged into the feature branch. This catches any conflicts before touching the base branch:

base (main):     A---B---C---D
                      \       \
feature:               E---F---G---M1 (merge base into feature)

If there are conflicts at this stage, the merge stops and you can resolve them in the feature branch without any risk to the base branch.

Phase 2: Fast-Forward Feature to Base

Once Phase 1 succeeds (feature branch now contains all base changes), the feature branch is fast-forwarded back into the base branch:

base (main):     A---B---C---D---M1 (fast-forward)
                      \       \ /
feature:               E---F---G---M1

Because Phase 1 already incorporated all base changes, Phase 2 is always a clean fast-forward.

Examples

Basic Merge

bash
owt merge feature/auth

Output:

Merging feature/auth into main...

Phase 1: Merging main into feature/auth...
  ✓ No conflicts

Phase 2: Fast-forwarding main to feature/auth...
  ✓ main updated

Cleanup:
  ✓ Killed tmux session: owt-feature-auth
  ✓ Removed worktree
  ✓ Cleared status tracking

Merge complete!

Merge to a Specific Base

bash
owt merge feature/api --base develop

Keep Worktree After Merge

bash
owt merge feature/auth --keep

The worktree and tmux session remain after merging. Useful if you want to continue working on follow-up tasks.

Skip Confirmation

bash
owt merge feature/auth --yes

Conflict Guard

Before starting the merge phases, Open Orchestrator checks for file-level overlaps between the feature branch and other active worktrees. If the same files are modified in multiple branches, you get a warning:

⚠ File overlap detected with 2 other worktrees:
  - api-refactor: src/routes/users.ts, src/middleware/auth.ts
  - db-migration: src/models/user.ts

Proceed anyway? [y/N]

This catches potential merge conflicts early -- before they become real git conflicts. Overlaps also surface in the Control Plane's NEEDS YOU section, where you can press f to fix (open the conflicted files).

Conflict Handling

If Phase 1 encounters conflicts:

Merging feature/auth into main...

Phase 1: Merging main into feature/auth...
  ✗ Merge conflicts detected:
    - src/auth/middleware.js
    - src/config/auth.ts

Resolve conflicts in the feature branch:
  owt switch feature/auth
  # Fix conflicts, then:
  git add .
  git commit -m "Resolve merge conflicts"
  # Then retry:
  owt merge feature/auth

The base branch is never modified during Phase 1, so conflicts are always safe to resolve.

Auto-Cleanup

After a successful merge (unless --keep is used), Open Orchestrator automatically:

  1. Kills the tmux session for the worktree
  2. Removes the git worktree directory
  3. Clears status tracking data for the worktree

This keeps your development environment clean after completing a task.

See Also

  • owt ship -- Commit + merge + delete in one shot
  • owt queue -- Optimal merge order for multiple worktrees
  • owt new -- Create worktrees
  • owt delete -- Delete without merging
  • owt sync -- Sync with upstream before merging