Two Agents, One Working Tree — What Broke When I Ran Parallel Claude Code Sessions in One Git Repository
Описание и применение
Параллельные сессии Claude Code в одном репозитории Git могут непреднамеренно включать чужие изменения в коммиты, стирая работу других сессий и нарушая трассируемость. Решения включают использование git commit --only <paths>, разделение проверки индекса и коммита, а также выделение отдельного worktree для каждой сессии.
Задача
Parallel Claude Code sessions operating in the same Git working tree can unintentionally incorporate or overwrite each other’s changes, leading to incorrect commits, lost work, and traceability issues.
Результат
Parallel sessions caused commits to include unintended files, overwritten work, and lost traceability. The author identified five real incidents and derived countermeasures such as using git commit --only <paths>, separating index inspection from commit, and assigning each session its own worktree.
Рабочий процесс
- 1. Start Claude Code session with a clean working tree.
- 2. Stage changes using
git add -Aorgit add <file>. - 3. Commit with
git commit -m "…"(no path). - 4. (Optional) Run
git statusafter commit, which is too late.
Доказательства
A session sees a repository with no pending changes when it starts. If a new or modified file appears during its run because a parallel session or the human has just created or changed it, that looks to the session exactly like a file its own tooling produced.
git commit without a path then commits the entire index, including everything someone else has already put there.
The rule file of this blog spells it out anyway, because then the command shows its intent.
- Дата записи: 2026-09-17T14:30:15.520Z