import { createFileRoute } from '@tanstack/react-router' export const Route = createFileRoute('/docs/worktrees')({ head: () => ({ meta: [ { title: 'Git Worktrees - Paseo Docs' }, { name: 'description', content: 'Run agents in isolated git worktrees for parallel feature development.', }, ], }), component: Worktrees, }) function Code({ children }: { children: React.ReactNode }) { return (
Git worktrees let you have multiple working directories from the same repository. Paseo uses them to run agents in isolated branches without switching contexts.
Without worktrees, running multiple agents on the same repo means they share the working directory. One agent's changes interfere with another's. You can't safely run parallel tasks.
With worktrees, each agent gets its own directory and branch. They can work simultaneously without conflict. When an agent finishes, you review the diff, merge the branch, and archive the worktree.
Paseo creates worktrees under $PASEO_HOME/worktrees/,
organized by a short hash of the source checkout path:
{`~/.paseo/worktrees/
├── 1vnnm9k3/
│ ├── tidy-fox/ # random slug
│ └── bold-owl/ # random slug
└── 4k8q2d1p/
└── swift-hare/ # random slug`}
The hash avoids collisions between repositories that share the same directory or remote name. Worktree directory names are random slugs — the branch name is separate and chosen when you first launch an agent in the worktree.
When you create a worktree, Paseo generates a random directory name. The branch name is set when you first launch an agent — Paseo generates one automatically.
This means the worktree directory and branch are independent. You can rename the branch later without affecting the worktree path.
You can launch multiple agents into the same worktree. They share the working directory and branch, which is useful when you want agents to collaborate on the same feature or when one agent hands off to another.
Be mindful of conflicts — agents working on the same files simultaneously can step on each other. This works best when agents have distinct responsibilities or run sequentially.
When Paseo creates a worktree, it's a fresh checkout. Dependencies aren't installed,
config files aren't copied. You can automate setup by creating a{' '}
paseo.json file in your repository root:
{`{
"worktree": {
"setup": [
"npm ci",
"cp \\"$PASEO_SOURCE_CHECKOUT_PATH/.env\\" \\"$PASEO_WORKTREE_PATH/.env\\""
]
}
}`}
The setup array contains shell commands that run
after the worktree is created. Use it to install dependencies, copy local config
files, or run any other initialization.
paseo.json in the selected base branch. If you pick{' '}
main, Paseo reads the committed file on{' '}
main. Local or uncommitted changes in another branch
are not used for that worktree.
Setup commands have access to these environment variables:
$PASEO_SOURCE_CHECKOUT_PATH — your source checkout
path (original repository root)
$PASEO_ROOT_PATH — legacy alias of{' '}
$PASEO_SOURCE_CHECKOUT_PATH
$PASEO_WORKTREE_PATH — the new worktree directory
$PASEO_BRANCH_NAME — the branch name created
$PASEO_WORKTREE_PORT — an available local port for setup scripts
Use $PASEO_SOURCE_CHECKOUT_PATH to copy files that
shouldn't be in git (like .env) from your source
checkout to the worktree.
{`{
"worktree": {
"setup": ["npm ci"]
}
}`}
{`{
"worktree": {
"setup": ["poetry install"]
}
}`}
{`{
"worktree": {
"setup": [
"npm ci",
"cp \\"$PASEO_SOURCE_CHECKOUT_PATH/.env\\" \\"$PASEO_WORKTREE_PATH/.env\\"",
"cp \\"$PASEO_SOURCE_CHECKOUT_PATH/.env.local\\" \\"$PASEO_WORKTREE_PATH/.env.local\\""
]
}
}`}
{`{
"worktree": {
"setup": [
"npm ci",
"cp \\"$PASEO_SOURCE_CHECKOUT_PATH/.env\\" \\"$PASEO_WORKTREE_PATH/.env\\"",
"npm run db:migrate"
]
}
}`}
The typical workflow is:
You can run multiple agents in different worktrees simultaneously. Each worktree has its own branch and working directory.
Create an agent in a new worktree:
{`paseo run --worktree feature-auth --base main "implement auth"`}
List all worktrees:
{`paseo worktree ls`}
Archive a worktree (stops agents, removes directory):
{`paseo worktree archive feature-auth`}
Paseo stores metadata in each worktree's git directory to track the base branch. This is used for diff operations and to know what branch to merge into.
You don't need to manage this manually — Paseo handles it when creating and archiving worktrees.