[BUG] Desktop app: session worktrees ignore `worktree.baseRef: "head"` and branch from origin/HEAD

Status Open
Reported on v2.1.209
Maintainer reply None cached
Activity 0 comments · opened Jul 28, 2026

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/HEADprod (production, protected, deploy target)
  • all day-to-day work happens on dev, and the main checkout sits on dev permanently

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

  1. Repo where origin/HEADprod and the working branch is dev.
  2. Main checkout is on dev. Confirm git symbolic-ref refs/remotes/origin/HEADrefs/remotes/origin/prod.
  3. Project .claude/settings.json contains:

``json
{ "worktree": { "baseRef": "head" } }
``

  1. In the desktop app, start a session with the worktree option ("start in worktree").
  2. 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/HEAD genuinely points at prod; that part is correct. The app resolved the default branch properly and then used it in spite of baseRef.
  • Not the main checkout being on the wrong branch. git reflog show HEAD confirms the main checkout was on dev commits continuously through the period the worktree was created; it was never on prod.
  • Not a malformed or unloaded settings file. .claude/settings.json parses as valid JSON and the key has been committed since 2026-07-07, three weeks before the worktree in question.
  • Not overridden elsewhere. No worktree key in ~/.claude/settings.json or .claude/settings.local.json.
  • Different code path from --worktree. The branch the app created was named claude/<generated-name>, not the documented worktree-<name> used by claude --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 branch dev; both on GitHub

Related

  • #80547 — desktop worktree base branch also wrong, and the reporter independently notes "the worktree.baseRef setting has no effect on this UI path". Their app substitutes a literal main; mine correctly resolves origin/HEAD and still ignores baseRef, so the symptoms differ but point at the same gap.
  • #76415 — worktree.bgIsolation likewise has no effect on interactive session worktree creation. Same shape: a worktree.* setting not reaching the desktop session path.
  • #41680 (closed) — --worktree branching from origin/HEAD rather than the current branch.

View original on GitHub ↗