Skip to main content

The {repo}-{name} Pattern

GWTree follows a consistent naming pattern for all worktrees:
This pattern ensures:
  • Predictability: Always know where to find worktrees
  • Organization: Related worktrees are grouped alphabetically
  • Clarity: The repository origin is immediately visible
  • Uniqueness: Avoid conflicts with existing directories

Pattern Implementation

From the source code (src/commands/create.ts:47, 224):
GWTree automatically:
  1. Detects the repository name from the git root directory
  2. Combines it with your chosen worktree name
  3. Creates the directory in the parent folder

Directory Structure

Single Repository Example

Multi-Repository Example

Worktrees for different repos naturally group together.

Naming Examples

Quick Creation

When you provide a name directly, it’s used for both the worktree and branch:
Creates:
  • Directory: my-repo-feature-auth/
  • Branch: feature-auth

Interactive Creation

During interactive mode:
Creates:
  • Directory: my-repo-dashboard-redesign/
  • Branch: dashboard-redesign

Separate Names (Advanced)

Press ESC during name input to specify different worktree and branch names:
Creates:
  • Directory: my-repo-ui-v2/
  • Branch: feature/dashboard-redesign
From src/commands/create.ts:181-221:

Valid Name Characters

GWTree validates names to ensure compatibility with both filesystems and git:

Allowed Characters

string
  • Letters: a-z, A-Z
  • Numbers: 0-9
  • Special: . (dot), _ (underscore), / (slash), - (hyphen)
Invalid characters:
  • Spaces: (use - or _ instead)
  • Special symbols: @, #, $, %, &, *, etc.

Naming Conventions

Feature Development

Bug Fixes

Experiments

Agent-Based Work

Branch Name Conflicts

GWTree automatically handles branch name conflicts by appending a counter:

Example

If branch feature already exists:
For batch creation:
From src/commands/create.ts:376-381:

Directory Path Preview

GWTree shows the full path before creation:
From src/commands/create.ts:169:
This helps you:
  • Verify the parent directory location
  • Understand the naming pattern
  • Catch potential path issues early

Batch Creation Naming

Create multiple worktrees with custom names:
Creates:
Each worktree:
  • Has its own branch with the same name
  • Lives in the parent directory
  • Follows the {repo}-{name} pattern
  • Gets dependencies installed automatically (if configured)

Edge Cases

Directory Already Exists

If the worktree directory already exists:
Solution: Choose a different name or remove the existing directory.

Long Repository Names

For repos with long names like my-super-long-repository-name:
Tip: Keep worktree names short to compensate for long repo names.

Special Characters in Repo Name

Repository names with special characters are preserved:

Finding Worktrees

List Command

View all worktrees for the current repository:
Output:

Remove by Name

The remove command searches by worktree name:
From src/commands/list.ts:168-172:

Merge by Name

Merge using any of these identifiers:
From src/commands/list.ts:467-471:

Best Practices

Recommended naming:
  • Use descriptive, lowercase names: user-dashboard, payment-flow
  • Include context: fix-login-bug, refactor-api-layer
  • Keep it short: auth instead of authentication-and-authorization
  • Use hyphens for readability: api-v2 not apiv2
Avoid:
  • Generic names: test, temp, new
  • Version numbers alone: v1, v2
  • Ambiguous abbreviations: stuff, things, misc
  • Special characters: feat@1, fix#123

Pattern Benefits

Consistency Across Projects

The same pattern works for any repository:

Easy Navigation

Tab completion works naturally:

Clean Organization

Alphabetical sorting groups related worktrees:

Learn More

Git Worktrees

Learn about git worktrees fundamentals

Multi-Agent Workflow

See how naming patterns enable parallel development