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:- Switches to main branch
- Merges the worktree branch
- Removes the worktree
- Deletes the branch
Arguments
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-authformyapp-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 committedError Handling
Uncommitted Changes
If the worktree has uncommitted changes:Merge Conflicts
If the merge has conflicts:Worktree Not Found
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:Step 3: Remove Worktree
Removes the worktree directory:Step 4: Delete Branch
Deletes the feature branch:-d (safe delete) which prevents deletion if branch isn’t fully merged.
Name Resolution
The<name> argument is flexible and matches:
myapp-feat with branch feature/auth-impl:
When to Use
Local Development
Merge completed features directly:After PR Merge
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)
Related Commands
- gwt status - Check if worktree is ready to merge
- gwt clean - Remove multiple merged worktrees
- gwt remove - Remove without merging