What it does
A git worktree is a second working directory backed by the same repository, checked out to a different branch. The history is shared; the files on disk are not. That property is what makes it the right primitive for parallel agents.
Without worktrees, two agents editing the same checkout race each other: one stages a file the other is mid-way through rewriting, and the result is a diff neither of them intended. With worktrees, each agent gets an isolated directory, works on its own branch, and you merge the results deliberately.
The practical pattern is one worktree per task rather than per agent. Spin one up for the refactor, another for the bug fix, let both run, then review the two branches as separate pull requests.
Using it
- Create a worktree. Cursor can create and manage worktrees from its interface, or use git worktree add ../feature-x -b feature-x from the terminal.
- Point an agent at it. Open the worktree directory and start the agent there. It sees only that checkout.
- Merge and remove. Review each branch on its own, merge what you want, then remove the worktree so stale checkouts do not pile up.
Checked against Worktrees documentation on 25 September 2026.