Worktrees
Git worktrees allow you to have multiple working directories from the same repository, each on a different branch. Autogit makes worktrees easy to manage and visualize.
Why Worktrees?
Section titled “Why Worktrees?”Parallel Development
Section titled “Parallel Development”Work on multiple features simultaneously without stashing or switching branches. Each worktree is an independent workspace with its own files.
Multi-Agent Development
Section titled “Multi-Agent Development”Worktrees are essential for running multiple AI coding agents in parallel. Each agent operates in its own isolated workspace, preventing conflicts and allowing true concurrent development.
Clean Separation
Section titled “Clean Separation”- No merge conflicts between in-progress work
- Each worktree has its own node_modules, build artifacts, etc.
- Switch between tasks instantly
Managing Worktrees
Section titled “Managing Worktrees”Autogit displays worktrees in the status tab with PR status indicators:
| Indicator | Meaning |
|---|---|
| Yellow dot | Draft PR open |
| Green dot | PR ready for review |
| No dot | No PR for this branch |
Keyboard Shortcuts
Section titled “Keyboard Shortcuts”| Key | Action |
|---|---|
| Enter | Switch to selected worktree |
| Ctrl+W | Create new worktree |
| Ctrl+Shift+W | Delete worktree |
| Ctrl+Shift+P | Prune dead worktrees |
| i | Show worktree info |
Worktree Location
Section titled “Worktree Location”Worktrees are created as siblings to your main repository:
~/projects/├── my-app/ # Main worktree (main branch)├── my-app-feature-1/ # Worktree for feature-1 branch├── my-app-feature-2/ # Worktree for feature-2 branch└── my-app-bugfix/ # Worktree for bugfix branchMulti-Agent Development
Section titled “Multi-Agent Development”Worktrees unlock the ability to run multiple AI coding agents simultaneously, each working on different issues without interfering with each other.
The Problem with Single Workspaces
Section titled “The Problem with Single Workspaces”When multiple agents share one workspace:
- File conflicts when agents edit the same files
- Unpredictable state as changes interleave
- Agents block each other waiting for file access
- Difficult to attribute changes to specific agents
The Worktree Solution
Section titled “The Worktree Solution”Each agent gets its own worktree:
- Complete isolation between agents
- No file locking or conflicts
- Parallel execution at full speed
- Clean git history per feature
Example: 3 Agents Working in Parallel
Section titled “Example: 3 Agents Working in Parallel”Imagine you have three issues to tackle:
- #42 - Add user authentication
- #43 - Implement dark mode
- #44 - Fix payment processing bug
Create three worktrees, one per issue:
~/projects/├── my-app/ # Main repo├── 42-auth/ # Agent 1: Claude Code├── 43-dark-mode/ # Agent 2: Codex CLI└── 44-payment-fix/ # Agent 3: OpenCodeWorkflow
Section titled “Workflow”Step-by-Step
Section titled “Step-by-Step”-
Create worktrees from issues (automatic)
In Autogit on main, select issue #42 and press
8(Smart PR). Autogit automatically:- Creates branch
42-add-user-authentication - Creates worktree at
~/projects/42-add-user-authentication/ - Switches to the new worktree
- Creates a draft PR linking to issue #42
Repeat for issues #43 and #44. Each gets its own isolated workspace.
- Creates branch
-
Launch agents in separate terminals
Terminal window # Terminal 1 - Claude Code on authcd ~/projects/42-add-user-authenticationclaude "Implement user authentication per issue #42"# Terminal 2 - Codex on dark modecd ~/projects/43-dark-modecodex "Add dark mode toggle per issue #43"# Terminal 3 - OpenCode on payment fixcd ~/projects/44-payment-fixopencode "Fix payment processing bug per issue #44" -
Agents work in parallel
Each agent:
- Reads and writes files in its own worktree
- Makes commits to its feature branch
- Pushes to the draft PR
- No conflicts with other agents
-
Review and merge
As each agent completes:
- Mark PR ready for review (press
8in that worktree) - Review the PR
- Merge to main
- Delete the worktree
- Mark PR ready for review (press
-
Monitor progress in Autogit
The worktrees panel shows all active work:
- Yellow dots = agents still working (draft PRs)
- Green dots = ready for review
- Switch between worktrees to check progress
Benefits
Section titled “Benefits”| Benefit | Description |
|---|---|
| True parallelism | 3 agents = 3x throughput (roughly) |
| No conflicts | Each agent has exclusive file access |
| Clean PRs | Each PR contains only relevant changes |
| Easy rollback | Delete worktree to abandon work |
| Visibility | Autogit shows all agent progress at a glance |
Best Practices
Section titled “Best Practices”For Multi-Agent Workflows
Section titled “For Multi-Agent Workflows”- One issue per worktree - Keep work focused and isolated
- Use draft PRs - Signals to other agents that work is in progress
- Name worktrees by issue - Easy to track which agent is doing what
- Prune regularly - Clean up merged worktrees with
Ctrl+Shift+P
For Solo Development
Section titled “For Solo Development”- Long-running tasks - Create worktree for refactors while fixing bugs on main
- Code review - Check out PR branches in separate worktrees
- Experiments - Try risky changes without affecting main work
Keyboard Reference
Section titled “Keyboard Reference”| Action | Key | Context |
|---|---|---|
| Create worktree | Ctrl+W | Worktrees panel |
| Delete worktree | Ctrl+Shift+W | Worktrees panel |
| Prune worktrees | Ctrl+Shift+P | Worktrees panel |
| Switch worktree | Enter | Worktrees panel |
| Worktree info | i | Worktrees panel |