Git worktrees are a powerful feature that allows you to have multiple working directories attached to a single repository. This is the foundation of Open Orchestrator's parallel development capabilities.
What is a Git Worktree?
A git worktree is an additional working tree linked to your repository. Unlike branches (which are just pointers), worktrees give you a complete working directory for a specific branch.
my-project/ # Main worktree (main branch)
my-project-feat-auth/ # Worktree for feat/auth
my-project-fix-login/ # Worktree for fix/loginEach worktree:
- Has its own working directory
- Can be on a different branch
- Shares the same git history
- Has independent staged/unstaged changes
Why Worktrees Instead of Multiple Clones?
| Feature | Multiple Clones | Git Worktrees |
|---|---|---|
| Disk space | Full copy each | Shared objects |
| Git history | Separate | Shared |
| Branch conflicts | Possible | Prevented |
| Setup time | Full clone | Instant |
With worktrees, you get the isolation of separate directories without duplicating your entire repository.
How Open Orchestrator Uses Worktrees
Task-Driven Creation
When you run owt new "Add user authentication", Open Orchestrator:
- Generates a branch name from your task description (e.g.,
feat/user-authentication) - Creates a git worktree in the configured base directory
- Creates and checks out the new branch
- Sets up the environment (installs dependencies, copies .env, etc.)
- Launches a tmux session with your configured AI tool
# Create a worktree from a task description
owt new "Add user authentication"
# With a specific template
owt new "Fix login timeout" -t bugfix
# With a specific AI tool
owt new "Build REST API" --ai-tool opencodeNaming Convention
By default, worktrees are named: {project}-{branch}
For a project called my-app with branch feat/user-authentication:
- Worktree path:
../my-app-feat-user-authentication/ - tmux session:
owt-feat-user-authentication
You can customize this in .worktreerc:
[worktree]
base_directory = "../worktrees"
naming_pattern = "{project}-{branch}"Branch Management
Open Orchestrator handles branch creation automatically through task descriptions. The branch naming algorithm converts your description into a properly formatted branch name with the appropriate prefix.
# Task-driven creation (recommended)
owt new "Add user authentication"
# Creates branch: feat/user-authentication
owt new "Fix the broken login page"
# Creates branch: fix/broken-login-page
owt new "Refactor database queries"
# Creates branch: refactor/database-queriesWorktree Constraints
Git enforces some rules for worktrees:
One Branch Per Worktree
You cannot have the same branch checked out in multiple worktrees. This prevents conflicting changes.
# If feat/auth is checked out in a worktree, this fails:
git checkout feat/auth # Error!Shared Git Objects
All worktrees share the same .git directory (or link to it). Changes committed in one worktree are immediately visible in others.
Pruning Stale Entries
If you delete a worktree directory manually, git may have stale references:
# Clean up stale worktree references
git worktree pruneOpen Orchestrator handles this automatically during cleanup.
Manual Worktree Commands
While Open Orchestrator manages worktrees for you, here are the underlying git commands:
# List worktrees
git worktree list
# Create a worktree
git worktree add ../path feature/branch
# Remove a worktree
git worktree remove ../path
# Prune stale references
git worktree pruneBest Practices
1. Keep Worktrees Organized
Use a consistent base directory for all worktrees:
[worktree]
base_directory = "../worktrees"This keeps your project directory clean.
2. Clean Up Regularly
Use the cleanup command to remove stale worktrees:
# Preview what would be cleaned
owt cleanup --dry-run
# Clean up worktrees older than 7 days
owt cleanup --days 73. Use the Control Plane for Navigation
Instead of manually tracking worktree sessions, use the Control Plane to see all active worktrees at a glance:
# Launch the Control Plane
owt4. Sync Before Long Sessions
Keep worktrees up to date with upstream:
owt sync --allTroubleshooting
"Branch is already checked out"
Another worktree has this branch. Either:
- Delete the existing worktree:
owt delete <name> - Use a different branch name
"Not a git repository"
Make sure you're in a git repository:
git statusStale Worktree Entries
If git worktree list shows entries that don't exist:
git worktree prune