[BUG] Worktree session gets passed incorrect branch name
Resolved 💬 3 comments Opened Mar 4, 2026 by tomgilder Closed Apr 2, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When running claude --worktree <name>, Claude gets told the current branch is the branch from _before_ the worktree was created.
The branch name seems to be injected into the system prompt as part of the startup context.
<img width="625" height="251" alt="Image" src="https://github.com/user-attachments/assets/de991dda-2841-4f06-8a90-3cad32d5567f" />
What Should Happen?
Run claude --worktree test and Claude knows it's on worktree-test.
Error Messages/Logs
Steps to Reproduce
- Run
claude --worktree test - Ask Claude "what branch are we on?"
It will give you the wrong answer.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.68
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗