EnterWorktree branches from origin/<default> instead of HEAD

Resolved 💬 5 comments Opened Apr 30, 2026 by Cycxyz Closed May 1, 2026

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

  1. In a clean checkout, ensure local master is ahead of origin/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
``

  1. Have Claude Code invoke EnterWorktree (e.g. ask it to "start a worktree").
  2. 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 master HEAD: 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 push before creating worktrees, so origin/master == master.
  • Create the worktree manually (git worktree add ... master) and pass path= to EnterWorktree.

Suggestion

Either:

  1. Make the actual behavior match the docs (branch from HEAD), or
  2. 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]

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗