Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: "Start from origin" bases new worktrees on the fork when main tracks upstream #17312

Closedtris203(GitHub profile, opens in a new tab) opened this issue 2 comments

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Clone a fork. Set origin to <you>/<repo> and add upstream for <org>/<repo>.
  2. Make local main track the source repository: git branch --set-upstream-to=upstream/main main.
  3. Let the fork's main fall behind upstream/main (do not sync the fork).
  4. Add the checkout as a T3 project and leave New worktrees start from origin on (the default).
  5. Start a new thread in a new worktree based on main.

Expected behavior

The worktree starts from the newest commit of the branch that main tracks, upstream/main. That is the branch Automatically pull already follows for the same checkout.

Actual behavior

The worktree starts from the fork's main, which is behind. Nothing fetches upstream.

The remote name is the literal string origin in both creation paths, so the base branch's configured tracking remote is never consulted:

  • ThreadLaunchService.ts checks that origin exists, runs fetchRemote({ remoteName: "origin", refName: baseRef }), then resolves the start commit with fallbackRemoteName: "origin". For baseRef: "main" that is refs/remotes/origin/main.
  • WorktreeMcpService.ts does the same for t3_worktree_handoff.

Choosing upstream/main as the base does not help. resolveRemoteTrackingCommit then reads refs/remotes/upstream/main, but the only fetch that ran was against origin, so the worktree starts from whatever upstream/main was at the last unrelated fetch.

I found this by reading main at 580948708b. I have not run it against a live server. My own fork's main currently matches upstream, so I am not hitting a stale base today.

A possible narrow fix: when the base branch has a configured tracking remote, fetch and resolve against that remote, and keep origin as the fallback when there is none. That is the rule git pull and Automatically pull already apply to the same branch.

Impact

Minor bug or occasional failure

Version or commit

main at 580948708b66f2a971199670f76cb6b43119e9a4 (2026-10-08)

Environment

Linux x86_64, Git 2.43.0. Fork checkout with origin = fork, upstream = source repository, branch.main.remote=upstream.

Workaround

Sync the fork's main before starting a worktree (gh repo sync <you>/<repo>), or turn New worktrees start from origin off and keep local main current yourself.

Each of these is a separate feature choosing a remote by its own rule in a fork checkout:

  • #15023: project identity prefers upstream and ignores gh repo set-default (fix open in #14291, which changes only RepositoryIdentityResolver).
  • #14843: merged-worktree cleanup checks the fork's default branch.
  • #7382: PR creation computes the head selector against origin.

Prepared with Claude Opus 5.5 through the Claude Code harness in T3 Code.

  1. I'm hitting this. My fork checkout has origin = my fork and upstream = pingdotgg/t3code, the usual fork setup. With New worktrees start from origin on, new worktrees fetch origin and branch from my fork's main, which is behind upstream.

    One note on the proposed fix: my local main tracks origin/main (branch.main.remote=origin), and I suspect that's common for fork setups. A fix that only follows the tracking remote wouldn't change anything for me until I run git branch -u upstream/main main. Two ways to cover that case: also prefer upstream when it exists (that's what pickPrimaryRemote already does for project identity), or document the -u step. Either way works for me.

  2. Fixed by #21032, merged at 673c5e3b3c. New worktrees and MCP handoffs now fetch the selected base branch’s configured remote before selecting the starting commit, including differently named upstream branches.

  3. juliusmarminge closed this

Sign in to join this conversation.