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
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
Use saved defaults and skip all prompts. Useful for quick worktree creation with pre-configured settings.
Skip opening the editor after worktree creation, even if configured in settings.
Behavior
When creating a worktree, GWTree performs the following steps:- Validation - Checks if you’re in a git repository
- Change handling - Detects uncommitted changes and offers to stash them
- Branch switching - Switches to main/master if not already there
- Update - Pulls latest changes from origin (if remote exists)
- Naming - Prompts for worktree and branch names (or uses provided arguments)
- Creation - Creates worktree with pattern
repo-name-suffix - Dependencies - Installs dependencies if configured (auto-detects package manager)
- 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:Separate Names Mode
Press ESC during name prompt to set worktree and branch names separately:myapp-feature-impl with branch feature/auth-implementation.
Command Line Mode
Provide the name as an argument:repo-name-feature-auth worktree with feature-auth branch.
Batch Mode
Create multiple worktrees at once:Examples
Basic Usage
Create a worktree interactively:Quick Creation
Create a worktree with a specific name: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.yaml→pnpm installbun.lockb→bun installyarn.lock→yarn installpackage-lock.json→npm installpackage.jsononly →pnpm install(default)
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)
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- Success1- Error (not a git repository, directory exists, git command failed)