A beautiful and simple CLI tool for managing git worktrees with automatic setup and configuration.
- 🎯 Simple commands:
new,list,switch,remove,clean - 🎨 Beautiful TUI with progress indicators
- 🤖 Agent-friendly non-interactive fallback when no TTY is available
- 🧾 Machine-friendly output flags:
--no-tui,--plain,--json - ⚡ Auto-copy files (.env, credentials, etc.) to new worktrees
- 🔧 Run setup commands automatically (npm install, etc.)
- 📁 Organized structure:
~/git-worktrees/<project>/<branch> - 🧹 Clean up merged branches easily
go install github.com/nachoal/gwt@latest- Initialize config in your project:
gwt init- Create a new worktree:
gwt new feature/awesome- List worktrees:
gwt list- Enable shell integration (add to ~/.zshrc):
# One-time install (zsh/bash):
gwt shell --install
# Writes a tiny source block to your rc and helper file under ~/.config/gwt/
# (for example ~/.config/gwt/shell.zsh)- Switch between worktrees:
gwt sw feature/awesomeEdit .worktree.yaml in your project:
version: 1
# Files to copy from main worktree
copy:
- .env
- .env.local
- credentials/
# Commands to run after creation
setup:
- npm install
- npm run prepare
settings:
root: ~/git-worktrees
auto_clean_merged: true
confirm_delete: truegwt init- Initialize config filegwt new <branch>- Create a new worktree (--no-tui,--plain,--json)gwt list- Show worktrees (--no-tui,--plain,--json)gwt switch <branch>- Change to worktree directorygwt remove <branch>- Delete a worktreegwt done [branch] [base]- Update base and remove the branch worktreegwt clean- Remove merged worktreesgwt version- Show version/build metadata and executable pathgwt -v/gwt --version- Short version output
Binary sanity check:
which -a gwtto find duplicate installations inPATHgwt version --jsonto confirm the executable path that actually ran
By default, gwt new and gwt list use TUI only when interactive TTY is available; otherwise they automatically fall back to non-TUI output.
With shell integration enabled, extra quality-of-life helpers are available:
gwt new feature/foo -c→ after creation, cd to the new worktree and run yourclaudealiasgwt new feature/foo -c "plan the changes"→ runsclaude "plan the changes"gwt new feature/foo -c issue https://link→ runsclaude "/issue-analysis https://link"gwt done [branch] [base]→ runs the real CLI command and then cd's to the base worktree- Tip: When run inside a worktree,
gwt donecan be used with no args; it infers the current branch and default base.
- Tip: When run inside a worktree,
Tip: If you previously had an alias named gwt, the installed function safely overrides it.