[BUG] Worktree branches created by Claude track origin/main as upstream
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 Claude Code creates a worktree (via claude -w or claude -w <name>), the new branch (e.g. worktree-<name>) is created tracking origin/main as its upstream. The branch is a local-only working branch with no corresponding remote branch, so tracking origin/main is misleading.
This appears to be an intentional choice in the worktree creation logic, but it differs from the default behavior of git worktree add -b, which creates a branch with no upstream tracking.
Is there a technical reason for always setting the upstream to origin/main?
What Should Happen?
The new branch should have no upstream tracking, since there's no remote branch it corresponds to.
Error Messages/Logs
Steps to Reproduce
- Run
claude -winside any git repository - Run
git branch -vvin the newly created worktree - The branch shows
[origin/main]as its upstream
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.76 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
Why it matters:
git statusshows "Your branch is up to date with 'origin/main'" or divergence info, which is irrelevant and confusing for a worktree branchgit pushwithout arguments may try to push tomain, which is almost certainly not the intent- It misrepresents the relationship between the worktree branch and the remote
Related: #30070 reports a different but connected issue where the hardcoded origin remote is wrong for repos that track a different upstream.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗