git-worktree-manager (gw)
CLI tool integrating git worktree with AI coding assistants. Single static binary (~1.9MB), instant startup (~3ms).
Supports macOS (ARM64/x86), Linux (ARM64/x86), and Windows (x86_64).
Successor to claude-worktree (Python).
Backward compatible: The
cwcommand is included as an alias. Existingcwworkflows,.cwshare, and.cwconfig.jsonfiles work unchanged.
Install
This installs both gw and cw binaries.
# Homebrew (macOS/Linux)
# cargo-binstall (pre-built binary, no compile)
# Direct download
# https://github.com/DaveDev42/git-worktree-manager/releases/latest
After installing, run gw upgrade at any time to update to the latest version (self-replacing binary). Homebrew users should use brew upgrade git-worktree-manager instead.
Quick Start
# Create a worktree and launch your AI coding assistant
# Create with a specific terminal launcher
# Create and pass an initial prompt to the AI tool
# List all worktrees
# Resume an AI session in an existing worktree
# Create a GitHub PR
# Merge back to base branch and clean up
Commands
| Command | Description |
|---|---|
gw new <name> |
Create worktree + launch AI tool |
gw resume [branch] |
Resume AI session in worktree |
gw shell [branch] |
Open shell in worktree |
gw pr [branch] |
Create GitHub PR |
gw merge [branch] |
Rebase + merge + cleanup |
gw delete <target> |
Remove worktree |
gw list |
List all worktrees |
gw status |
Show current worktree info |
gw tree |
Visual tree display |
gw stats |
Usage analytics |
gw diff <b1> <b2> |
Compare branches |
gw sync [branch] |
Rebase on base branch |
gw change-base <new-base> [branch] |
Change base branch for worktree |
gw clean |
Batch cleanup (--merged, --older-than) |
gw backup create/list/restore |
Git bundle backup |
gw stash save/list/apply |
Worktree-aware stash |
gw hook add/remove/list/... |
Lifecycle hooks |
gw config ... |
Configuration management |
gw export / gw import |
Config export/import |
gw doctor |
Health check diagnostics |
gw upgrade |
Self-update to latest version |
gw scan |
Register repos for global mode |
gw prune |
Clean up stale registry entries |
gw setup-claude |
Install Claude Code skill |
gw shell-setup |
Interactive shell integration setup |
gw -g <cmd> |
Global mode (cross-repo) |
Terminal Launchers
Control how AI tools are launched with --term (or configure a default via gw config set launch.method):
| Launcher | Variants |
|---|---|
| Foreground | foreground (default) |
| Detached | detach |
| iTerm | iterm-window, iterm-tab, iterm-pane-h, iterm-pane-v |
| tmux | tmux, tmux-window, tmux-pane-h, tmux-pane-v |
| Zellij | zellij, zellij-tab, zellij-pane-h, zellij-pane-v |
| WezTerm | wezterm-window, wezterm-tab, wezterm-tab-bg, wezterm-pane-h, wezterm-pane-v |
Each launcher also has a short alias (e.g., t for tmux, i-t for iterm-tab).
Claude Code Integration
Delegate coding tasks to isolated worktrees directly from Claude Code:
Once installed, use the /gw slash command or natural language in Claude Code to delegate tasks. Each task runs in its own worktree with a separate Claude Code instance.
Shell Integration
# Interactive setup (recommended)
# bash/zsh - add to your shell rc file
# fish
|
This enables:
gw-cd <branch>- Navigate to a worktree directory (interactive selector if no args)- Tab completion - Branch names, config keys, and options
Generate shell completions separately with gw --generate-completion <bash|zsh|fish|powershell|elvish>.
Configuration
Config file: ~/.config/git-worktree-manager/config.json (also reads legacy ~/.config/claude-worktree/config.json)
AI Tool Presets
Environment Variables
| Variable | Description |
|---|---|
CW_AI_TOOL |
Override AI tool command (space-separated) |
CW_LAUNCH_METHOD |
Override terminal launch method |
Hooks
Run custom commands at lifecycle events. Pre-hooks abort the operation on failure.
Available events: worktree.pre_create, worktree.post_create, worktree.pre_delete, worktree.post_delete, merge.pre, merge.post, pr.pre, pr.post, resume.pre, resume.post, sync.pre, sync.post
Hook context is passed via CW_* environment variables.
License
BSD-3-Clause