stablyai/orca · error · Error

Could not resolve a default base ref for this repo. Pick a b

Error message

Could not resolve a default base ref for this repo. Pick a base branch explicitly and try again.

What it means

Remote worktree create could not resolve a default base ref to build the worktree from. getOrStartRemoteWorktreeCreateBasePlan returned null. The code deliberately does NOT fall back to a hardcoded 'origin/main' because that ref may not exist (the repo could default to master/develop/trunk), and passing a nonexistent ref to git worktree add yields an opaque error. Instead it fails clearly so the UI can prompt the user to pick a base branch explicitly.

Source

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

  let effectiveSanitizedName = sanitizedName
  const requestedDisplayName = args.displayName
    ? sanitizeWorktreeDisplayName(args.displayName)
    : undefined

  // Why: base resolution probes refs via generic git.exec; register the repo root first so relays don't report a valid base as stale.
  await registerRequiredSshWorktreeCreateRoots(repo.connectionId!, [repo.path])

  // Why: explicit branches and non-username prefix modes never consume this; skipping the remote probe preserves the exact branch name.
  const username =
    !args.branchNameOverride && settings.branchPrefix === 'git-username'
      ? await getSshGitUsername(provider, repo.path)
      : ''

  const branchConflictSubject = args.branchNameOverride ? 'branch name' : 'worktree name'
  // Why: don't fall back to hardcoded 'origin/main'; it may not exist (master/develop) and yields an opaque git error, so fail clearly and let the UI prompt.
  const basePlan = await getOrStartRemoteWorktreeCreateBasePlan(provider, repo, args.baseBranch)
  if (!basePlan) {
    throw new Error(
      'Could not resolve a default base ref for this repo. Pick a base branch explicitly and try again.'
    )
  }
  let { baseBranch } = basePlan
  let { remoteTrackingBase } = basePlan
  let baseFallback: WorktreeCreateBaseFallback | undefined

  if (remoteTrackingBase) {
    const hasRemoteTrackingBaseRef = await hasRemoteTrackingRefSsh(
      provider,
      repo.path,
      remoteTrackingBase.ref
    )
    const hasNamedLocalBaseRef = await hasRemoteWorktreeBaseRef(provider, repo.path, baseBranch)
    const hasFallbackLocalBaseRef =
      !hasNamedLocalBaseRef &&
      (await hasRemoteWorktreeBaseRef(provider, repo.path, remoteTrackingBase.branch))
    if (!hasRemoteTrackingBaseRef && (hasNamedLocalBaseRef || hasFallbackLocalBaseRef)) {

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Pass an explicit args.baseBranch (e.g. the repo's real default) so the resolver never has to guess.
  2. Verify the remote repo actually exposes its default branch ref (register roots, then list refs).
  3. Configure the repo's default branch in Orca settings so future creates resolve automatically.

Example fix

// before
const basePlan = await getOrStartRemoteWorktreeCreateBasePlan(provider, repo, args.baseBranch)
if (!basePlan) {
  throw new Error('Could not resolve a default base ref for this repo. Pick a base branch explicitly and try again.')
}

// after — surface candidates so the UI can prefill the prompt
if (!basePlan) {
  const candidates = await listRemoteDefaultBranchCandidates(provider, repo.path)
  throw new BaseRefUnresolvedError(candidates)
}
Defensive patterns

Strategy: validation

Validate before calling

// Resolve a base before create; prompt the user if none is found
let base = args.baseBranch ?? store.getRepoDefaultBranch(repo.id)
if (!base) {
  const candidates = await listRemoteDefaultBranchCandidates(provider, repo.path)
  if (candidates.length === 0) {
    return { ok: false, error: 'No default base branch found. Pick one explicitly.' }
  }
  base = await promptUserForBaseBranch(candidates)
}

Try / catch

catch (err) {
  if (err instanceof Error && err.message.startsWith('Could not resolve a default base ref')) {
    openBaseBranchPicker(repo)
  } else { throw err }
}

Prevention

When it happens

Trigger: Remote (SSH) worktree create with no args.baseBranch, on a repo whose base-plan resolver (resolveRemoteWorktreeCreateBasePlan) could not determine a default — e.g. no obvious main branch, no configured default, or all candidate refs missing on the remote. Reached at worktree-remote.ts:1516.

Common situations: Freshly cloned repo with an unusual default branch (trunk, develop, production); remote has no refs visible because roots aren't registered yet; repo with multiple heads and no declared default; base-plan probe ran before registerRequiredSshWorktreeCreateRoots completed in a prior run.

Related errors


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