DEV Community

Aasim Sani
Aasim Sani

Posted on

🪟 gwt — Stupidly Simple Git Worktrees in PowerShell. 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, first for zsh, and now ported to PowerShell after Windows users kept asking.

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

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

gwt demo


What it does

Stacking

Create worktrees from your current branch and navigate the chain:

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

# Navigate
gwt ..    # parent worktree
gwt ...   # root worktree
Enter fullscreen mode Exit fullscreen mode

Smart naming

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

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

Interactive menus

Numbered menus for branch selection and pruning. Search through your branches when creating worktrees, multi-select when cleaning up old ones.

gwt              # pick from branches
gwt --prune      # or -Prune, multi-select worktrees to remove
gwt --list       # or -List, see the whole tree
Enter fullscreen mode Exit fullscreen mode

Config copying

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

Post-create hooks

$env:GWT_POST_CREATE_CMD = "npm install"
Enter fullscreen mode Exit fullscreen mode

Installation

# PSGallery
Install-Module -Name GWT -Scope CurrentUser

# Add to your $PROFILE:
Import-Module GWT
Enter fullscreen mode Exit fullscreen mode

Works on Windows and macOS (PowerShell 7+).

Commands

Supports both --flag and -Flag syntax:

gwt feature/branch            # Create from main
gwt --stack feature/x         # or -Stack, create from current branch
gwt --from dev feature/x      # or -From, create from specific branch

gwt ..                        # Parent worktree
gwt ...                       # Root worktree

gwt --list                    # or -List, see all worktrees
gwt --info                    # or -Info, stack info
gwt --prune                   # or -Prune, interactive cleanup
gwt --config                  # or -Config, configure settings
Enter fullscreen mode Exit fullscreen mode

Why this matters for Claude Code users

Claude Code works best when you give it a clean worktree: isolated context, no uncommitted changes from other work bleeding in. gwt makes spinning up those worktrees instant instead of a chore.


GitHub: aasimsani/gwt-powershell

ZSH version: aasimsani/gwt-zsh

Feedback welcome.

Top comments (0)