DEV Community

Aasim Sani
Aasim Sani

Posted on

🌳 gwt — Stupidly Simple Git Worktrees. Isolated Branches for AI Coding.

What are git worktrees?

Worktrees let you check out multiple branches at once, each in its own folder. No more stashing and switching, just open another directory.

If you've used them, you know this pain:

git worktree add ../myrepo-feature ../myrepo-feature feature/branch
cd ../myrepo-feature
cp -r ../myrepo/.vscode .
npm install
claude
Enter fullscreen mode Exit fullscreen mode

Every single time.

I got tired of it. So I built gwt.

gwt feature/new-thing
Enter fullscreen mode Exit fullscreen mode

Creates the worktree, auto-names it, cd's you in, configs copied, Claude Code started, repo set up.

gwt demo


Yet another git worktree tool? Yeah. gwq, branchlet, git-worktree-runner, wt... they all exist. But I'm impatient. Everything else made me type too much.

Here's what gwt does:

Stacking

Run gwt child-branch from any worktree and it branches from where you are. gwt .. goes back to parent, gwt ... to root.

# You're in feature/api-v2
gwt --stack feature/api-v2-tests

# Navigate the chain
gwt ..    # back to feature/api-v2
gwt ...   # back to main
Enter fullscreen mode Exit fullscreen mode

Smart naming

Linear-style branches like aasim/eng-1234-add-feature become repo-eng-1234. Regular branches use first few words.

gwt aasim/eng-1234-add-user-authentication
# Creates: ../myrepo-eng-1234

gwt feature/add-new-dashboard-components  
# Creates: ../myrepo-add-new-dashboard
Enter fullscreen mode Exit fullscreen mode

Tab completion & fuzzy finding

Full zsh autocompletion for all commands, flags, branches, and worktree names. If you have fzf installed, gwt uses it everywhere: fuzzy search through branches, multi-select when pruning. No fzf? Falls back to numbered menus.

gwt          # fzf picker for branches
gwt --prune  # multi-select worktrees to remove
gwt --list   # see the whole tree at a glance
Enter fullscreen mode Exit fullscreen mode

Config copying

Automatically copies .vscode/, .env, or whatever dirs you configure to new worktrees.

export GWT_COPY_DIRS=".vscode,.env,.idea"
gwt feature/new-thing  # .vscode/ already there
Enter fullscreen mode Exit fullscreen mode

Post-create hooks

Run any command after creation: npm install, claude, code ., uv sync, whatever.

export GWT_POST_CREATE_CMD="npm install && claude"
Enter fullscreen mode Exit fullscreen mode

Setup

# Oh-My-Zsh
git clone https://github.com/aasimsani/gwt-zsh \
  ~/.oh-my-zsh/custom/plugins/gwt
omz plugin enable gwt

# Or:
zinit light aasimsani/gwt-zsh
antigen bundle aasimsani/gwt-zsh
zplug "aasimsani/gwt-zsh"
Enter fullscreen mode Exit fullscreen mode

Commands

gwt feature/branch       # Create from main
gwt --stack feature/x    # Create from current branch
gwt --from dev feature/x # Create from specific branch

gwt ..                   # Go to parent worktree
gwt ...                  # Go to root worktree

gwt --list               # See all worktrees with hierarchy
gwt --info               # Stack info for current worktree
gwt --prune              # Interactive cleanup
gwt --config             # Configure settings
Enter fullscreen mode Exit fullscreen mode

Claude Code integration

If you use Claude Code:

gwt --setup-skill
Enter fullscreen mode Exit fullscreen mode

Then /gwt in any session loads the command reference.


GitHub: aasimsani/gwt-zsh

PowerShell version: aasimsani/gwt-powershell

Looking for feedback, happy with an honest roast too.

Top comments (0)