website/docs/user-guide/git-worktrees.md
Hermes Agent is often used on large, long‑lived repositories. When you want to:
Git worktrees are the safest way to give each agent its own checkout without duplicating the entire repository.
This page shows how to combine worktrees with Hermes so each session has a clean, isolated working directory.
Hermes treats the current working directory as the project root:
hermes or hermes chatterminal.cwd in ~/.hermes/config.yamlIf you run multiple agents in the same checkout, their changes can interfere with each other:
With worktrees, each agent gets:
/rollbackSee also: Checkpoints and /rollback.
From your main repository (containing .git/), create a new worktree for a feature branch:
# From the main repo root
cd /path/to/your/repo
# Create a new branch and worktree in ../repo-feature
git worktree add ../repo-feature feature/hermes-experiment
This creates:
../repo-featurefeature/hermes-experiment checked out in that directoryNow you can cd into the new worktree and run Hermes there:
cd ../repo-feature
# Start Hermes in the worktree
hermes
Hermes will:
../repo-feature as the project root./rollback scoped to this worktree.You can create multiple worktrees, each with its own branch:
cd /path/to/your/repo
git worktree add ../repo-experiment-a feature/hermes-a
git worktree add ../repo-experiment-b feature/hermes-b
In separate terminals:
# Terminal 1
cd ../repo-experiment-a
hermes
# Terminal 2
cd ../repo-experiment-b
hermes
Each Hermes process:
feature/hermes-a vs feature/hermes-b)./rollback independently without affecting the other.This is especially useful when:
When you are done with an experiment:
cd /path/to/your/repo
# Remove the worktree directory and its reference
git worktree remove ../repo-feature
Notes:
git worktree remove will refuse to remove a worktree with uncommitted changes unless you force it.git branch commands.~/.hermes/checkpoints/ is not automatically pruned when you remove a worktree, but it is usually very small.feature/hermes-checkpoints-docs, feature/hermes-refactor-tests.hermes -w (Automatic Worktree Mode)Hermes has a built‑in -w flag that automatically creates a disposable git worktree with its own branch. You don't need to set up worktrees manually — just cd into your repo and run:
cd /path/to/your/repo
hermes -w
Hermes will:
.worktrees/ inside your repo.hermes/hermes-<hash>).This is the easiest way to get worktree isolation. You can also combine it with a single query:
hermes -w -z "Fix issue #123"
For parallel agents, open multiple terminals and run hermes -w in each — every invocation gets its own worktree and branch automatically.
/rollback to recover from mistakes inside each worktree.This combination gives you: