Skip to main content

Syntax

Description

The default command creates one or more git worktrees with automated setup including dependency installation and editor integration. When no name is provided, it prompts for input. When multiple names are provided, it creates multiple worktrees in batch mode.

Arguments

string[]
Name(s) for worktree and branch. If omitted, prompts for input. If multiple names provided (e.g., gwt foo bar), creates multiple worktrees in batch mode.

Options

flag
Use saved defaults and skip all prompts. Useful for quick worktree creation with pre-configured settings.
flag
Skip opening the editor after worktree creation, even if configured in settings.

Behavior

When creating a worktree, GWTree performs the following steps:
  1. Validation - Checks if you’re in a git repository
  2. Change handling - Detects uncommitted changes and offers to stash them
  3. Branch switching - Switches to main/master if not already there
  4. Update - Pulls latest changes from origin (if remote exists)
  5. Naming - Prompts for worktree and branch names (or uses provided arguments)
  6. Creation - Creates worktree with pattern repo-name-suffix
  7. Dependencies - Installs dependencies if configured (auto-detects package manager)
  8. Editor - Opens in configured editor if not disabled

Interactive Modes

Single Worktree Mode

When no arguments are provided, GWTree prompts for a combined worktree/branch name:
Example output:

Separate Names Mode

Press ESC during name prompt to set worktree and branch names separately:
This creates worktree myapp-feature-impl with branch feature/auth-implementation.

Command Line Mode

Provide the name as an argument:
Skips the name prompt and creates repo-name-feature-auth worktree with feature-auth branch.

Batch Mode

Create multiple worktrees at once:
Example output:

Examples

Basic Usage

Create a worktree interactively:

Quick Creation

Create a worktree with a specific name:
Creates myrepo-feature-login worktree with feature-login branch.

Fast Mode

Use saved defaults, skip all prompts:

No Editor

Create without opening editor:

Batch Creation

Create multiple worktrees:

Combined Flags

Quick batch creation without editor:

Branch Naming

If a branch with the specified name already exists, GWTree automatically appends a counter:

Worktree Naming Pattern

Worktrees are always created as siblings to the main repository:

Package Manager Detection

GWTree automatically detects the package manager from lock files:
  • pnpm-lock.yamlpnpm install
  • bun.lockbbun install
  • yarn.lockyarn install
  • package-lock.jsonnpm install
  • package.json only → pnpm install (default)
The detected package manager is saved for future worktrees.

Configuration

The create command respects these config settings:
  • editor - Which editor to open (code, cursor, default, none)
  • installDeps - Whether to install dependencies automatically
  • lastPm - Last used package manager (auto-detected)
See gwt config to modify these settings.

Prompts (Interactive Mode)

When not using -y flag, you may see these prompts:

Uncommitted Changes

Not on Main Branch

Pull Latest Changes

Exit Codes

  • 0 - Success
  • 1 - Error (not a git repository, directory exists, git command failed)