EnterWorktree branches from origin/<default> instead of HEAD
Summary
The EnterWorktree tool's documentation states it creates a new worktree "with a new branch based on HEAD", but in practice it branches from origin/<default-branch> — even when local master/main is ahead of the remote and HEAD is on the local branch (not detached).
Repro
- In a clean checkout, ensure local
masteris ahead oforigin/master:
````
git checkout master
git log --oneline origin/master..master # shows N local-only commits
git rev-parse HEAD master origin/master # HEAD == master, both ahead of origin/master
- Have Claude Code invoke
EnterWorktree(e.g. ask it to "start a worktree"). - Inspect the new branch:
````
git reflog show <new-worktree-branch>
Expected
Per the tool's docstring, the new branch should be created from HEAD (i.e. local master).
Actual
The reflog shows the branch was created from origin/master:
250ec80 worktree-deploy_scripts@{1}: branch: Created from origin/master
Concrete numbers from my repro:
- Local
masterHEAD:63ecb8d(committed 2026-04-30 10:02) - Worktree directory created: 2026-04-30 10:22 (20 minutes later)
- Worktree branch base:
250ec80=origin/master(not HEAD)
HEAD was not detached; I had committed directly to local master and those commits had not yet been pushed.
Impact
Surprising and silently destructive-feeling: any unpushed work on local master is invisible to the new worktree. The user has to discover the discrepancy and git merge --ff-only master after the fact.
Workarounds
git fetch && git pushbefore creating worktrees, soorigin/master == master.- Create the worktree manually (
git worktree add ... master) and passpath=toEnterWorktree.
Suggestion
Either:
- Make the actual behavior match the docs (branch from HEAD), or
- Document that the base is
origin/<default>, and expose a setting / parameter to override it.
Environment
- Platform: darwin 24.2.0
- Model: claude-opus-4-7[1m]
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗