Git Worktrees

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.

Why Use Worktrees with Hermes?

Hermes treats the current working directory as the project root:

If you run multiple agents in the same checkout, their changes can interfere with each other:

With worktrees, each agent gets:

See also: Checkpoints and /rollback.

Quick Start: Creating a Worktree

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:

Now you can cd into the new worktree and run Hermes there:

cd ../repo-feature

# Start Hermes in the worktree
hermes

Hermes will:

Running Multiple Agents in Parallel

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:

This is especially useful when:

Cleaning Up Worktrees Safely

When you are done with an experiment:

  1. Decide whether to keep or discard the work.
  2. If you want to keep it:
    • Merge the branch into your main branch as usual.
  3. Remove the worktree:
cd /path/to/your/repo

# Remove the worktree directory and its reference
git worktree remove ../repo-feature

Notes:

Best Practices

Using 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:

This is the easiest way to get worktree isolation. You can also combine it with a single query:

hermes -w -q "Fix issue #123"

For parallel agents, open multiple terminals and run hermes -w in each — every invocation gets its own worktree and branch automatically.

Putting It All Together

This combination gives you: