Git Worktrees
Git worktrees let you have multiple branches checked out at the same time, each in its own directory. CACD is built around this concept - each AI agent session runs on its own worktree, so agents can work on different branches without conflicts.
What Are Worktrees?
Section titled “What Are Worktrees?”Normally, a Git repository has one working directory. If you want to work on a different branch, you have to stash or commit your changes and switch branches.
With worktrees, you can have feature-a checked out in one folder and feature-b in another, simultaneously. Both share the same Git history but have independent working directories.
Why Use Worktrees with AI Agents?
Section titled “Why Use Worktrees with AI Agents?”- Parallel work - Run Claude on
feature-loginwhile Gemini works onfeature-dashboard - No conflicts - Each agent has its own sandbox
- Easy comparison - Switch between branches without losing context
- Clean isolation - Agent changes don’t affect your main working directory
Creating a Worktree
Section titled “Creating a Worktree”From the WebUI:
- Click New Worktree or create one while starting a new session
- Enter a branch name (new or existing)
- Optionally specify a directory path (or let CACD auto-generate it)
- Click Create
CACD creates the worktree and you can immediately start a session on it.
Auto-Directory
Section titled “Auto-Directory”By default, CACD can auto-generate worktree paths based on branch names. Enable this in settings to skip manually entering paths every time.
The pattern uses {branch} as a placeholder. For example, with pattern ../worktrees/{branch}:
- Branch
feature/loginbecomes../worktrees/feature-login - Branch names are sanitized to be filesystem-safe
Merging a Worktree
Section titled “Merging a Worktree”When you’re done with a feature:
- Select the worktree
- Click Merge
- Choose whether to use rebase
- Confirm
CACD merges the worktree’s branch into your target branch (typically main).
Deleting a Worktree
Section titled “Deleting a Worktree”- Select the worktree
- Click Delete
- Optionally delete the branch as well
- Confirm
The worktree directory is removed. If you had sessions running on it, they’ll be terminated.
- Keep worktrees in a sibling directory (like
../worktrees/) to keep things organized - Use descriptive branch names - they’ll become your worktree identifiers
- Don’t forget to merge or clean up worktrees when you’re done with a feature