EnterWorktree branches from origin/main instead of local HEAD

Resolved 💬 3 comments Opened Mar 26, 2026 by nel Closed Mar 26, 2026

Problem

EnterWorktree creates worktrees based on origin/main (last fetched remote state) rather than the local branch HEAD. This silently ignores unpushed local commits with no warning.

The tool description says "creates a new branch based on HEAD", but in practice it uses the remote-tracking ref.

Reproduction

  1. Be on main with unpushed commits (e.g. 101 commits ahead of origin)
  2. Ask Claude to create a worktree
  3. The worktree is created from origin/main, not local main

Evidence from reflog:

# Worktree branch created from origin/main (yesterday's state)
2026-03-25 17:15:09  991826f  branch: Created from origin/main

# But local main was already 101 commits ahead at worktree creation time
# Worktree .git file birth time: 2026-03-26 17:39:06
# Local main HEAD at that time: 50f42d0 (2026-03-26 17:21:50)

Expected behavior

Match git worktree add semantics: branch from the current local HEAD. Terminal users expect their local working state to be the starting point, not a potentially stale remote ref.

Suggested fix

  • Use local branch HEAD (matching native git worktree behavior), OR
  • At minimum, warn when local branch is ahead of origin (e.g. "Local main is 101 commits ahead of origin/main. Worktree will be based on origin/main — push first?")

Context

This is particularly problematic for users who batch commits locally and push periodically. The worktree silently starts from a stale state, and any work done in it may conflict or miss recent changes.

View original on GitHub ↗

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