EnterWorktree ignores worktree.baseRef: "fresh" — still branches from local HEAD (v2.1.144)
Summary
In Claude Code v2.1.144, EnterWorktree ignores the documented worktree.baseRef: "fresh" default (and explicit setting) and creates the new branch from local HEAD instead of origin/<default-branch>.
Confirmed via reflog: branch: Created from HEAD.
This looks like a regression of the bug that was reported and closed for Agent({ isolation: "worktree" }) in #60235 — same root cause re-surfacing on the EnterWorktree code path. Earlier closed issues #54940 / #39506 / #27134 describe the same direction of bug pre-v2.1.128.
Environment
- Claude Code: v2.1.144 (Linux ELF,
~/.local/share/claude/versions/2.1.144) - Platform: Linux 6.17.0-23-generic
~/.claude/settings.jsoncontains:
``json`
"worktree": { "baseRef": "fresh" }
fresh
Schema-valid (confirmed against the binary's published JSONSchema). Per the v2.1.133 changelog (referenced in #57148), = branch from origin/<default-branch>` is the documented default.
Reproduce
In any git repo with origin/<default-branch> configured, with the session checked out on a feature branch ahead of origin/<default>:
# pre-state
$ git symbolic-ref refs/remotes/origin/HEAD # refs/remotes/origin/master
$ git rev-parse --abbrev-ref HEAD # feature-branch (not master)
$ git rev-parse HEAD # <SHA-A>
$ git rev-parse origin/master # <SHA-B> (different SHA)
Then in a Claude Code session, invoke:
EnterWorktree(name="test-baseref")
Inside the new worktree:
$ git rev-parse HEAD
<SHA-A> # ← matches local HEAD, not origin/master
$ git reflog show worktree-test-baseref
<SHA-A> worktree-test-baseref@{0}: branch: Created from HEAD
Expected
Per the JSONSchema description:
worktree.baseRef:'fresh'(default) branches fromorigin/<default-branch>for a clean tree.
New branch should be at origin/master (<SHA-B>), reflog should show Created from origin/master.
Actual
New branch is at local HEAD. Reflog shows Created from HEAD. The harness appears to be invoking git worktree add -b <branch> <path> with no explicit base ref.
Impact
Same impact pattern as #54940 / #39506 / #27134 in reverse: local-only commits on the current feature branch silently leak into every new worktree. When that worktree is later pushed as a PR, the diff contains commits not authored in this session — triggering force-push cleanup and stale reviewer comments. The fresh setting was specifically designed to prevent this, and it's not taking effect.
Suggested fix
Make EnterWorktree's worktree-creation path honor worktree.baseRef. The fix that landed for Agent({ isolation: "worktree" }) in #60235 likely just needs to be applied to the EnterWorktree code path as well.
Workaround
None via config. Users must manually git fetch and check the reflog of every worktree branch before pushing — which defeats the purpose of the setting.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗