Base worktrees on origin/main
git worktree add ../DPF-<topic> -b feat/<branch> origin/main —
never main, never HEAD. Local main is often ahead of or behind
origin/main due to unpushed commits, in-flight rebases, or merges
from other concurrent sessions; basing a new feature branch on local
main sweeps that drift into the PR and fails DCO / sign-off checks.
Why this exists
Local main is not a reliable baseline. It can be:
- Ahead of
origin/mainwith unpushed commits from a prior session - Behind
origin/mainbecause the operator’s pull lagged a merge - Mid-rebase from a concurrent session
A new worktree branched off local main inherits whichever of those
states the local clone happens to be in. The branch is then not what
the operator + reviewer think it is, and the resulting PR either:
- Has unrelated commits sweep in (failing DCO, polluting the diff)
- Drops commits that were already merged elsewhere (looking like a rollback)
- Conflicts in ways that aren’t actually conflicts in
origin/main
What to do
When creating a worktree:
git -C D:/DPF fetch origin main --quiet
git -C D:/DPF worktree add D:/DPF-<topic> -b <branch-name> origin/main
Three precise verbs:
fetch origin mainfirst — ensure the local ref oforigin/mainis freshworktree addthe worktree directory- Base the new branch on
origin/mainexplicitly (notHEAD, notmain)
Verify before claiming done
Per structural-verification-is-not-functional,
verify PR-level checks before claiming the work is done. Local
“tests pass” is not the same as “the PR’s CI is green.” The PR view
itself is the ground truth.
Anti-pattern
git worktree add ../DPF-X -b feat/X(no base specified → defaults to HEAD)git worktree add ../DPF-X -b feat/X main(uses local main, may be stale or ahead)- Branching off
HEADof a worktree that was itself branched off stale local main → compounded staleness
Related principles
worktree-per-session— one worktree per concurrent sessionsweep-main-before-trusting-worktree-specs— local worktrees go stale; trustorigin/mainonlyall-changes-land-via-pr— all changes ship through a PR off a current base