claude-code - 💡(How to fix) Fix EnterWorktree ignores worktree.baseRef: "fresh" — still branches from local HEAD (v2.1.144) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#60588Fetched 2026-05-20 03:54:39
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×5commented ×1

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.

Root Cause

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.

Fix Action

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.

Code Example

"worktree": { "baseRef": "fresh" }

---

# 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)

---

EnterWorktree(name="test-baseref")

---

$ 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
RAW_BUFFERClick to expand / collapse

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.json contains:
    "worktree": { "baseRef": "fresh" }
    Schema-valid (confirmed against the binary's published JSONSchema). Per the v2.1.133 changelog (referenced in #57148), fresh = 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 from origin/<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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix EnterWorktree ignores worktree.baseRef: "fresh" — still branches from local HEAD (v2.1.144) [1 comments, 2 participants]