[BUG] Worktree branches created by Claude track origin/main as upstream

Resolved 💬 5 comments Opened Mar 14, 2026 by aarnone Closed May 12, 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 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

  1. Run claude -w inside any git repository
  2. Run git branch -vv in the newly created worktree
  3. 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 status shows "Your branch is up to date with 'origin/main'" or divergence info, which is irrelevant and confusing for a worktree branch
  • git push without arguments may try to push to main, 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.

View original on GitHub ↗

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