Skip to main content

Syntax

Description

Merges a worktree’s branch into main and removes both the worktree and the branch. This is a complete cleanup operation for finished work. The command performs all steps needed to complete a feature:
  1. Switches to main branch
  2. Merges the worktree branch
  3. Removes the worktree
  4. Deletes the branch

Arguments

string
required
Name of the worktree to merge. Can be:
  • Branch name (e.g., feature-auth)
  • Worktree directory name (e.g., myapp-feature-auth)
  • Worktree suffix (e.g., feature-auth for myapp-feature-auth)

Aliases

  • m - Short alias for merge

Workflow

Examples

Merge by branch name

Merge by worktree name

Merge by suffix

Using short alias

Prerequisites

The worktree must have: No uncommitted changes - All changes must be committed

Error Handling

Uncommitted Changes

If the worktree has uncommitted changes:
Solution:

Merge Conflicts

If the merge has conflicts:
Solution:

Worktree Not Found

Check available worktrees:

Merge Process Details

Step 1: Switch to Main

Switches the main repository to the main branch:

Step 2: Merge Branch

Merges the worktree’s branch into main:
This performs a standard git merge. If fast-forward is possible, it does a fast-forward merge. Otherwise, it creates a merge commit.

Step 3: Remove Worktree

Removes the worktree directory:
Also removes the entry from GWTree’s registry.

Step 4: Delete Branch

Deletes the feature branch:
Uses -d (safe delete) which prevents deletion if branch isn’t fully merged.

Name Resolution

The <name> argument is flexible and matches:
For worktree myapp-feat with branch feature/auth-impl:

When to Use

Local Development

Merge completed features directly:

After PR Merge

If your feature was merged via GitHub PR, you should:
  1. Pull the merged changes: git pull
  2. Just remove the worktree: gwt clean or gwt remove
Do NOT use gwt merge as the branch is already merged.

Hotfixes

Quickly merge urgent fixes:

Comparison with Manual Process

Using gwt merge

Manual equivalent

Integration with PR Workflow

GitHub/GitLab Merge

Local Merge

Exit Codes

  • 0 - Success (branch merged, worktree removed, branch deleted)
  • 1 - Error (worktree not found, uncommitted changes, merge conflict, not in git repository)