[BUG] `--worktree` creates worktree/branch based on wrong remote

Resolved 💬 3 comments Opened Mar 2, 2026 by kevinansfield Closed May 4, 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?

My main branch is set to track upstream/main but claude --worktree always creates the branch based off origin/main which is rarely used and so usually very out of date.

What Should Happen?

Worktree creation should use the git tracking configuration or at least allow the remote it uses to be configured in settings.

Error Messages/Logs

Steps to Reproduce

  1. Set up two git remotes, in my case upstream/main (primary work trunk) and origin/main (rarely used fork)
  2. Ensure local main is configured to track the right remote git branch --set-upstream-to=upstream/main main
  3. Make commits to upstream/main so that it is ahead of origin/main
  4. Run claude -w
  5. Inspect the created worktree/branch - it will be behind upstream/main because it's based off origin/main

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.1.63

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

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