# Git worktrees: run several coding agents in parallel

Canonical: [Git worktrees: run several coding agents in parallel](https://contextingo.com/blog/git-worktrees-parallel-coding-agents)

Locale: en

Purpose: A worktree gives each agent its own folder and branch on the same repository. The commands, the limits, and how to keep the work coordinated.

Content updated: 2026-09-18

Source revision: content.ts 2026-09-18

Maintenance owner: the Contextingo site owner

[Topic map](https://contextingo.com/llm/topics/blog.md) · [Complete scoped map](https://contextingo.com/sitemap.md)

Two agents editing the same folder will trip over each other. Git has a built-in answer: worktrees. A worktree is another working folder for the same repository, checked out on its own branch, sharing one object database.

## The commands

```
git worktree add ../app-fix-login -b fix-login
git worktree list
git worktree remove ../app-fix-login
```

The first command creates a folder next to your repository with a new branch `fix-login`. Start one agent session in each folder.

## What you get

- Each agent has its own files and its own branch, so uncommitted edits do not collide.
- History and objects are shared, so a worktree is quick to create and uses little disk space.
- Git refuses to check out the same branch in two worktrees, which prevents the worst mix-ups.

## What you do not get

- **Separate dependencies.** Untracked folders such as `node_modules` are per worktree, so each one needs an install.
- **Separate ports and databases.** Two dev servers on one port still collide.
- **Shared understanding.** Two agents in two folders do not know what the other found.

## Keep them coordinated

Give each worktree one issue. Let each agent save findings and failed attempts to the project while it works, so the second agent does not repeat the dead end of the first. Merge through pull requests, one per branch, each reviewed by a person.

On Contextingo each agent session starts on an issue with `session_start`, so two worktrees on two issues share one project knowledge. See [how a handover works](/guides/hand-off-claude-code-task-to-teammate).

## Questions

### Is a worktree the same as a clone?

No. A clone copies the repository. A worktree is an extra working folder that shares the repository’s history.

### How do I clean up?

Run `git worktree remove <path>` after the branch is merged, and `git worktree prune` to clear stale entries.
