gitStatus context reports wrong branch when launched with -w <worktree>

Resolved 💬 3 comments Opened Apr 27, 2026 by azarovalex Closed May 30, 2026

When launching Claude Code with claude -w <worktree-name>, the session's CWD is correctly set to the worktree directory, but the gitStatus snapshot in the initial system context reports the branch of the main checkout rather than the worktree's branch.

Repro:

  1. In a repo with a worktree (e.g. .claude/worktrees/my-worktree) checked out to branch B, with the main checkout on branch A.
  2. Launch claude -w my-worktree.
  3. Ask Claude what branch it's on — it will answer with A (from the stale gitStatus snapshot).
  4. Running git branch --show-current correctly reports B.

Expected: gitStatus reflects the branch of the worktree the session was launched into.

Impact: Claude answers questions about current branch state incorrectly until it runs a git command, since it trusts the initial snapshot.

View original on GitHub ↗

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