stablyai/orca · error · Error

Base ref "${baseBranch}" was not found after fetching.

Error message

Base ref "${baseBranch}" was not found after fetching.

What it means

Local worktree create: the base ref was NOT present locally before the refresh (hadLocalBaseRef false), the refresh completed, but a follow-up runtime.hasRemoteTrackingRef still reports the ref is absent. This means the fetch succeeded (didn't throw) but the requested base ref genuinely does not exist on the remote — wrong branch name, deleted upstream, or typo. Distinct from 1335, which fires when the fetch itself fails.

Source

Thrown at src/main/ipc/worktree-remote.ts:2235

  if (remoteTrackingRefresh) {
    await timing.time('refresh_base_ref', async () => {
      const result = await remoteTrackingRefresh.promise
      if (!result.ok && !remoteTrackingRefresh.hadLocalBaseRef) {
        // Why: only block create when the refresh failed AND there's no local base ref; an existing (possibly stale) ref keeps worktree add viable.
        throw new Error(
          `Could not refresh base ref "${baseBranch}" from "${remoteTrackingRefresh.base.remote}". Check your network and try again.`
        )
      }
      if (
        !remoteTrackingRefresh.hadLocalBaseRef &&
        !(await runtime?.hasRemoteTrackingRef(
          repo.path,
          remoteTrackingRefresh.base,
          ...localWorktreeGitOptionArgs
        ))
      ) {
        throw new Error(`Base ref "${baseBranch}" was not found after fetching.`)
      }
    })
  }

  if (legacyFetchPromise) {
    await timing.time('refresh_base_ref', async () => {
      await legacyFetchPromise
    })
  }
  emitCreateWorktreeProgress(mainWindow, 'creating', args.creationId)

  let preparedPushTarget: GitPushTarget | undefined
  if (args.pushTarget) {
    // Why: validate/fetch the contributor remote before create so a failure doesn't leave a half-created worktree with conflicts on retry.
    preparedPushTarget = await prepareWorktreePushTarget(
      repo.path,
      args.pushTarget,
      store,

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Verify the base branch name against git ls-remote --heads origin and correct it.
  2. Update the repo's remote refspec (git remote set-branches) so the ref is fetched.
  3. Pick a base branch that is known to exist on the remote.
Defensive patterns

Strategy: validation

Validate before calling

// Verify the base branch actually exists on the remote before create
const refs = await listRemoteHeads(repo, 'origin')
if (!refs.includes(baseBranch)) {
  return { ok: false, fieldError: 'baseBranch', message: `Base branch "${baseBranch}" does not exist on origin.` }
}

Try / catch

catch (err) {
  if (err instanceof Error && /was not found after fetching/.test(err.message)) {
    openBaseBranchPicker(repo, { reason: 'ref-missing' })
  } else { throw err }
}

Prevention

When it happens

Trigger: Local create where hadLocalBaseRef is false, remoteTrackingRefresh.promise resolved ok (or ok=false but not blocking), yet runtime.hasRemoteTrackingRef(repo.path, base, ...) returns false. Reached at worktree-remote.ts:2235.

Common situations: User typed a base branch name that doesn't exist on origin; upstream branch was renamed/deleted; fetch pulled other refs but not this one due to refspec config; case mismatch in branch name; shallow clone with narrow refspec.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/58afcd22c0a396b4. Report an issue: GitHub.