A convenient CLI tool for managing Git worktrees with automatic package manager setup.
- Create worktrees with simple commands
- Checkout existing branches as worktrees
- Automatic detection and setup of package managers (npm, yarn, pnpm, cargo, go, pip, bundler)
- Copy untracked environment files (.env, .env.local, etc.) to new worktrees
- Interactive worktree selection for removal
- Interactive branch selection for checkout
- Safety checks before removing worktrees (uncommitted changes, unpushed commits, merge status)
- Cross-platform support (macOS, Linux)
go install github.com/sotarok/gw@latestDownload the latest binary for your platform from the Releases page.
# AMD64
curl -L https://github.com/sotarok/gw/releases/latest/download/gw_Linux_x86_64.tar.gz | tar xz
sudo mv gw /usr/local/bin/
# ARM64
curl -L https://github.com/sotarok/gw/releases/latest/download/gw_Linux_arm64.tar.gz | tar xz
sudo mv gw /usr/local/bin/# Intel Mac
curl -L https://github.com/sotarok/gw/releases/latest/download/gw_Darwin_x86_64.tar.gz | tar xz
sudo mv gw /usr/local/bin/
# Apple Silicon
curl -L https://github.com/sotarok/gw/releases/latest/download/gw_Darwin_arm64.tar.gz | tar xz
sudo mv gw /usr/local/bin/git clone https://github.com/sotarok/gw.git
cd gw
make install# Create worktree for issue #123 based on main branch
gw start 123
# Create worktree based on specific branch
gw start 456 develop
# Create worktree and copy environment files
gw start 789 --copy-envsThis will:
- Create a new worktree at
../{repository-name}-{issue-number} - Create a new branch
{issue-number}/impl - Change to the new worktree directory
- Optionally copy untracked .env files from the original repository
- Automatically run package manager setup if detected
# Checkout specific branch as worktree
gw checkout feature/auth
# Checkout remote branch
gw checkout origin/feature/api
# Interactive mode - select from list of branches
gw checkout
# Checkout and copy environment files
gw checkout feature/auth --copy-envsThis will:
- Create a new worktree at
../{repository-name}-{branch-name} - Checkout the specified branch (or create tracking branch for remote)
- Change to the new worktree directory
- Optionally copy untracked .env files from the original repository
- Automatically run package manager setup if detected
# Remove specific worktree
gw end 123
# Interactive mode - select from list
gw end
# Force removal without safety checks
gw end 123 --forceSafety checks include:
- Uncommitted changes
- Unpushed commits
- Merge status with origin/main
Future versions will support configuration via .gwconfig file for:
- Default base branch
- Custom worktree location
- Package manager preferences
gw/
├── cmd/ # Command implementations
├── internal/
│ ├── git/ # Git operations
│ ├── detect/ # Package manager detection
│ ├── ui/ # Interactive UI components
│ └── config/ # Configuration management
├── main.go
└── go.mod
go build -o gwgo test ./...MIT