GUIDE · GIT WORKTREES

Separate the folders. Plan the integration.

Git worktree lets you check out different branches of one repository in separate folders. It separates file writes; it does not guarantee that independently written changes will fit together.

Arenor · Updated

When is a worktree useful?

Two independent features may need separate working directories rather than both agents writing on the same branch. Worktrees provide that separation. Shared package caches, service ports and external databases can still collide.

This guide first shows a manual Git workflow. The last section explains Arenor’s different behavior: its optional isolation is per run, not per agent.

1. Create a fresh demo repository

Run these commands only in a new example directory. You need Git and Python 3. Use this two-file fixture instead of experimenting on an existing project. The demo author identity is configured only for this repository.

mkdir arenor-worktree-demo
cd arenor-worktree-demo
git init -b main
git config user.name "Arenor Demo"
git config user.email "demo@example.invalid"
printf "label=Save\n" > button.txt
cat > check.py <<'PYTEST'
from pathlib import Path
label = Path("button.txt").read_text().strip()
assert label in {"label=Save", "label=Save changes"}, label
print("PASS: button label accepted")
PYTEST
git add button.txt check.py
git -c commit.gpgsign=false commit -m "Create demo"
git worktree add -b agent-ui ../agent-ui
git worktree add -b agent-review ../agent-review
git worktree list
Both worktrees start at the initial commit. Choose fresh directory names if these already exist. Commit signing is disabled only for the individual demo commands.

2. Change one folder and inspect the others

The review worktree does not see the change yet. Naming a file is not enough when giving agents instructions; specify which directory each one should use.

printf "label=Save changes\n" > ../agent-ui/button.txt
(cd ../agent-ui && python3 check.py)
git -C ../agent-ui diff -- button.txt
cat button.txt
cat ../agent-review/button.txt
The check prints PASS. The main and review folders still contain label=Save.

3. Update the review worktree

In a real project, stage only the intended files after checking the diff, tests and untracked files. --ff-only stops instead of making an automatic merge commit if the review branch has diverged. That failure calls for another review.

git -C ../agent-ui add button.txt
git -C ../agent-ui -c commit.gpgsign=false commit -m "Clarify button label"
git -C ../agent-review merge --ff-only agent-ui
(cd ../agent-review && python3 check.py)
The review branch has not diverged, so fast-forward succeeds. The main folder’s main branch is unchanged. Commit signing is disabled only for the individual demo commands.

4. Reproduce a conflict

The two branches changed the same line differently. Worktrees kept files separate during editing; they did not prevent an integration conflict. Everything was committed before this merge in the fresh demo, so the next command can abandon the attempt. Preserve any existing local work first when working in a real repository.

printf "label=Save draft\n" > ../agent-review/button.txt
git -C ../agent-review add button.txt
git -C ../agent-review -c commit.gpgsign=false commit -m "Demonstrate conflicting label"
printf "label=Save now\n" > ../agent-ui/button.txt
git -C ../agent-ui add button.txt
git -C ../agent-ui -c commit.gpgsign=false commit -m "Alternative label for conflict demo"
git -C ../agent-ui merge agent-review
git -C ../agent-ui status --short
Failure of the merge command is expected here. You should see UU for button.txt and conflict markers in the file. Commit signing is disabled only for the individual demo commands.

5. Leave the test merge

When finished, use git worktree remove for clean worktrees. If a folder has uncommitted changes, decide what to keep first. This guide does not use forced removal or reset.

git -C ../agent-ui merge --abort
cat ../agent-ui/button.txt
git worktree list
The UI folder returns to label=Save now, its pre-merge state. The worktrees remain available for inspection.

How this differs inside Arenor

  • With Git isolation enabled, Arenor creates one worktree per run, shared by that run’s members.
  • It starts from HEAD. Uncommitted files in the main directory are not copied into it.
  • A creation failure can warn and fall back to the main folder; check isolation status.
  • Applying a run back compares the baseline, run and current main-folder files. It is not the Git merge operation shown above.
  • After review, commit/push is a separate user choice. A worktree is not a network or permission sandbox.

Verification record

On October 2, 2026, Git 2.54.0 and Python 3 were used in a fresh temporary repository to check isolation, a passing test, fast-forward review, an intentional line conflict and merge --abort. No model calls or real user projects were used. Verifying this workflow does not prove that agent-generated code is correct.

Questions

Do worktrees prevent every conflict?

No. They separate working directories. Changes to the same files or behavior can still need review when integrated.

Does Arenor create a worktree for each agent?

No. Optional isolation is per run. Plan member file scopes and dependencies separately within that run.

Arenor plan approval screen with two demo tasks and acceptance criteria
Actual Arenor screen with anonymous sample data.

Sources