GWTree provides commands to merge your work back to the main branch and automatically clean up worktrees when they’re no longer needed.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ahmadawais/gwtree/llms.txt
Use this file to discover all available pages before exploring further.
Merge Command
Merge a worktree’s branch to main and remove the worktree:Finding Worktrees by Name
The merge command accepts different name formats:- Exact branch name match
- Worktree directory name match
- Worktree suffix match (without repo prefix)
Merge Workflow
cd ../myrepo-feature-auth && git add . && git commitcd ../myrepo-feature-auth && git stashgit worktree remove "{path}" --forcerm -rf if needed│
│ ◆ Branch git branch -d feature-auth
│ └ branch deleted
│
└ Done Merged and cleaned up feature-auth
Merge Failures
Uncommitted Changes
Merge Conflicts
- The main repository is left in a conflicted state
- Navigate to the main repo
- Resolve conflicts manually
- Complete the merge with
git commit - Remove the worktree manually with
gwt rm
Clean Command
Automatically remove worktrees that have been merged to main:Clean Merged Worktrees
By default,gwt clean removes only merged worktrees:
How Merge Detection Works
GWTree determines if a worktree is merged by running:Clean All Worktrees
Remove ALL worktrees regardless of merge status:Clean Workflow
│
│ ◆ Removed myrepo-bug-fix
│ └ /path/to/parent/myrepo-bug-fix
│
│ ◆ Removed myrepo-feature-old
│ └ /path/to/parent/myrepo-feature-old
│
└ Done Removed 2 worktrees
No Worktrees to Clean
If no worktrees match the criteria:Recommended Workflow
Combine commands for an efficient workflow:1. Check Status
See which worktrees are ready:2. Merge Ready Worktrees
Merge worktrees that are ready:- Merges the branch to main
- Removes the worktree
- Deletes the branch
3. Clean Up Merged Worktrees
Remove any remaining merged worktrees:4. Continue Working
Focus on in-progress worktrees:Examples
Merge Single Worktree
Clean After PR Merges
After merging PRs on GitHub:Emergency Cleanup
Remove all worktrees quickly:Selective Merge
Comparison Table
| Command | Purpose | Removes | Merges | Deletes Branch |
|---|---|---|---|---|
gwt merge <name> | Merge specific worktree | Yes | Yes | Yes |
gwt clean | Remove merged worktrees | Yes | No | No |
gwt clean --all | Remove all worktrees | Yes | No | No |
gwt rm | Manually remove worktrees | Yes | No | No |
When to Use Each Command
Use gwt merge when:
- You’re ready to merge work to main
- You want to merge and clean up in one step
- You’re working with local branches (no PR)
- You want the branch deleted automatically
Use gwt clean when:
- Branches were merged via pull requests
- You have multiple merged worktrees to remove
- You want to preview before removing
- You want to clean up old worktrees
Use gwt rm when:
- You want to abandon work without merging
- You need fine-grained control over removal
- You want to remove specific worktrees
- You want to search and select interactively
Next Steps
- Learn about configuration to customize behavior
- Review managing worktrees for tracking commands
- Return to creating worktrees to start new work