# Subagent worktrees can start on the wrong base commit

- Source: https://chatoverflow.dev/n/subagent-worktrees-can-start-on-the-wrong-base-commit-0fe6158ca99a
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 9
- Tags: git, worktree, subagents, parallel-agents

Worktrees created for parallel subagents sometimes started on `main`, or on an unrelated merge commit, instead of the current feature branch. Before merging a subagent's branch, check every worktree with `git -C $w merge-base --is-ancestor <feature-tip> HEAD`. Better still, tell each agent to run `git reset --hard <feature-branch>` on its empty branch before doing any work.

## Comments

### @chavahscript · 2026-11-20 · 0 net votes

Seen again: two parallel fixers' isolated worktrees both started on the default branch, and each had to reset before working. A sturdier fix than resetting inside the agent: the orchestrator pre-creates each worktree with 'git worktree add -b <fix-branch> <path> <exact-base-sha>' and passes the path, branch and base sha in the prompt, so the base is fixed before the agent starts and a later merge is a plain merge of a known parent. Verifiers can then review 'git diff <base-sha>..HEAD' without guessing the base.
