[BUG] Desktop app: session worktrees ignore `worktree.baseRef: "head"` and branch from origin/HEAD
Bug Description
worktree.baseRef: "head" is set in project .claude/settings.json, but worktrees created for desktop-app sessions ignore it and branch from the repository's default branch (origin/HEAD) anyway.
This repo's layout is the common one where the default branch is not the working branch:
origin/HEAD→prod(production, protected, deploy target)- all day-to-day work happens on
dev, and the main checkout sits ondevpermanently
With baseRef: "head" I expect a session worktree to branch from the main checkout's HEAD (dev). Instead every session worktree is cut from prod, which on this repo is weeks of merge commits behind dev.
The practical damage is not just stale code. Because the worktree's branch is rooted in prod, merging it back into dev wants to bring along every prod-only merge commit (30 in my case, of which 2 were mine), i.e. it back-merges production into the integration branch. A plain git rebase dev is no better: it starts replaying those prod-only commits and stops on conflicts in unrelated code. Cherry-picking the session's own commits is the only clean recovery, and it needs manual conflict resolution because the commits' diff base is the wrong branch.
Steps to reproduce
- Repo where
origin/HEAD→prodand the working branch isdev. - Main checkout is on
dev. Confirmgit symbolic-ref refs/remotes/origin/HEAD→refs/remotes/origin/prod. - Project
.claude/settings.jsoncontains:
``json``
{ "worktree": { "baseRef": "head" } }
- In the desktop app, start a session with the worktree option ("start in worktree").
- Inspect the new worktree:
git log --oneline -1.
Result: the worktree is based at the tip of prod (origin/HEAD), not dev.
Expected behavior
With worktree.baseRef: "head", a desktop session worktree should branch from the main checkout's current HEAD (dev), the same as the documented behavior for --worktree and for subagent isolation.
Failing that, the docs should state plainly that worktree.baseRef does not apply to desktop session worktrees. The worktrees page currently groups desktop parallel sessions with the other worktree kinds when describing .worktreeinclude ("applies to every worktree Claude Code creates with git: --worktree worktrees, subagent worktrees, and parallel sessions in the desktop app"), and describes baseRef under a general "Customize worktree creation" heading, so reading it as session-wide is a reasonable interpretation.
What I ruled out
- Not a stale or wrong
origin/HEAD.origin/HEADgenuinely points atprod; that part is correct. The app resolved the default branch properly and then used it in spite ofbaseRef. - Not the main checkout being on the wrong branch.
git reflog show HEADconfirms the main checkout was ondevcommits continuously through the period the worktree was created; it was never onprod. - Not a malformed or unloaded settings file.
.claude/settings.jsonparses as valid JSON and the key has been committed since 2026-07-07, three weeks before the worktree in question. - Not overridden elsewhere. No
worktreekey in~/.claude/settings.jsonor.claude/settings.local.json. - Different code path from
--worktree. The branch the app created was namedclaude/<generated-name>, not the documentedworktree-<name>used byclaude --worktree, which suggests session worktrees go through separate creation logic.
Environment
- Claude Code CLI 2.1.209
- macOS (Darwin 25.5.0, arm64)
- Repo default branch
prod; working branchdev; both on GitHub
Related
- #80547 — desktop worktree base branch also wrong, and the reporter independently notes "the
worktree.baseRefsetting has no effect on this UI path". Their app substitutes a literalmain; mine correctly resolvesorigin/HEADand still ignoresbaseRef, so the symptoms differ but point at the same gap. - #76415 —
worktree.bgIsolationlikewise has no effect on interactive session worktree creation. Same shape: aworktree.*setting not reaching the desktop session path. - #41680 (closed) —
--worktreebranching fromorigin/HEADrather than the current branch.