﻿---
title: Worktrees
description: Every task gets its own git worktree, so agents never share a checkout.
url: https://docs-v3-preview.elastic.dev/concepts/worktrees
---

# Worktrees
Every session works in its own [git worktree](https://git-scm.com/docs/git-worktree): a separate checkout of the repo on
its own branch. Agents never share a working tree, so two of them can change the same repo at once, and your main
checkout stays yours.
![The Repos view's worktree table: every added worktree, its branch, agent, status and pull request](https://docs-v3-preview.elastic.dev/images/shots/concepts/worktrees.png)
- Worktrees go under `~/code/wt/<repo>/<name>` (set `root` under `[worktrees]`).
- The branch name comes from the prompt: see [Branch names](https://docs-v3-preview.elastic.dev/start-work/branch-names).
- A cross-repo session gets a worktree in each repo, on the same branch name.
- Worktrees made outside Heed can be [imported](https://docs-v3-preview.elastic.dev/worktrees/importing) as sessions.

Heed never removes a worktree with uncommitted changes or unpushed commits. See [Removing](https://docs-v3-preview.elastic.dev/worktrees/removing)
and [Cleanup](https://docs-v3-preview.elastic.dev/worktrees/cleanup).