Skip to main content

Create your first worktree

Navigate to any git repository and create a worktree:
1

Interactive mode

Run gwt without arguments for an interactive prompt:
You’ll be guided through:
  1. Name — Enter name for both worktree and branch (press ESC to set separately)
  2. Stash/Switch — Handle uncommitted changes and switch to main
  3. Pull — Fetch latest changes from remote
Press ESC during name input to set worktree and branch names separately.
2

Quick mode

Pass a name directly to skip prompts:
This creates:
  • Worktree: repo-feature-login/
  • Branch: feature-login
The CLI shows each command as it runs:
3

Navigate to worktree

Change to your new worktree directory:
Your editor should already be open with the new worktree.

Multi-agent parallel development

The real power of GWTree is creating multiple worktrees for parallel AI agent development:
This creates three isolated worktrees:
The -x flag (or --no-editor) skips opening editors — perfect for batch creation.
Now run different AI agents in each worktree:
  • Claude Code in repo-auth/
  • Command Code in repo-api/
  • Cursor in repo-dashboard/

Fast mode with defaults

Skip all prompts using your saved config:
The -y or --yes flag uses saved defaults for stash, pull, and editor preferences.

List worktrees

See all worktrees for the current repo:
Output:

Check status

See the status of all worktrees:
Shows for each worktree:
  • Changed files
  • Commits ahead/behind main
  • Merge readiness
  • Line additions/deletions

Merge and cleanup

When a feature is complete, merge it back to main:
This automatically:
  1. Switches to main branch
  2. Merges the feature branch
  3. Removes the worktree
  4. Deletes the branch
Make sure all changes are committed before merging. The command will fail if there are uncommitted changes.

Clean merged worktrees

Remove all worktrees that have been merged to main:
Remove all worktrees (merged or not):

Remove specific worktrees

Interactive search and remove:
Use fuzzy search to find and remove worktrees:

Essential commands

Package manager detection

GWTree automatically detects your package manager:
  • pnpm-lock.yaml → uses pnpm install
  • bun.lockb → uses bun install
  • yarn.lock → uses yarn install
  • package-lock.json → uses npm install
  • package.json only → defaults to pnpm install
Set installDeps: false in config to disable automatic dependency installation.

What’s next?

You’re ready to use GWTree for parallel AI agent development! Here are some tips:

Workflow tip

Use gwt status frequently to track progress across all worktrees

Clean habit

Run gwt clean regularly to remove merged worktrees

Fast creation

Use -x flag for batch creation: gwt a b c -x

Configuration

Customize editor and install preferences with gwt config