Skip to content

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.

Work on multiple features simultaneously without stashing or switching branches. Each worktree is an independent workspace with its own files.

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.

  • No merge conflicts between in-progress work
  • Each worktree has its own node_modules, build artifacts, etc.
  • Switch between tasks instantly

Autogit displays worktrees in the status tab with PR status indicators:

IndicatorMeaning
Yellow dotDraft PR open
Green dotPR ready for review
No dotNo PR for this branch
KeyAction
EnterSwitch to selected worktree
Ctrl+WCreate new worktree
Ctrl+Shift+WDelete worktree
Ctrl+Shift+PPrune dead worktrees
iShow worktree info

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 branch

Worktrees unlock the ability to run multiple AI coding agents simultaneously, each working on different issues without interfering with each other.

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

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

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: OpenCode
  1. 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.

  2. Launch agents in separate terminals

    Terminal window
    # Terminal 1 - Claude Code on auth
    cd ~/projects/42-add-user-authentication
    claude "Implement user authentication per issue #42"
    # Terminal 2 - Codex on dark mode
    cd ~/projects/43-dark-mode
    codex "Add dark mode toggle per issue #43"
    # Terminal 3 - OpenCode on payment fix
    cd ~/projects/44-payment-fix
    opencode "Fix payment processing bug per issue #44"
  3. 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
  4. Review and merge

    As each agent completes:

    • Mark PR ready for review (press 8 in that worktree)
    • Review the PR
    • Merge to main
    • Delete the worktree
  5. 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
BenefitDescription
True parallelism3 agents = 3x throughput (roughly)
No conflictsEach agent has exclusive file access
Clean PRsEach PR contains only relevant changes
Easy rollbackDelete worktree to abandon work
VisibilityAutogit shows all agent progress at a glance

  1. One issue per worktree - Keep work focused and isolated
  2. Use draft PRs - Signals to other agents that work is in progress
  3. Name worktrees by issue - Easy to track which agent is doing what
  4. Prune regularly - Clean up merged worktrees with Ctrl+Shift+P
  1. Long-running tasks - Create worktree for refactors while fixing bugs on main
  2. Code review - Check out PR branches in separate worktrees
  3. Experiments - Try risky changes without affecting main work

ActionKeyContext
Create worktreeCtrl+WWorktrees panel
Delete worktreeCtrl+Shift+WWorktrees panel
Prune worktreesCtrl+Shift+PWorktrees panel
Switch worktreeEnterWorktrees panel
Worktree infoiWorktrees panel