{"record":{"id":"e212823a82149ff8","repo":"stablyai/orca","slug":"could-not-resolve-a-default-base-ref-for-this-repo","errorCode":null,"errorMessage":"Could not resolve a default base ref for this repo. Pick a base branch explicitly and try again.","messagePattern":"Could not resolve a default base ref for this repo\\. Pick a base branch explicitly and try again\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ipc/worktree-remote.ts","lineNumber":1516,"sourceCode":"  let effectiveSanitizedName = sanitizedName\n  const requestedDisplayName = args.displayName\n    ? sanitizeWorktreeDisplayName(args.displayName)\n    : undefined\n\n  // Why: base resolution probes refs via generic git.exec; register the repo root first so relays don't report a valid base as stale.\n  await registerRequiredSshWorktreeCreateRoots(repo.connectionId!, [repo.path])\n\n  // Why: explicit branches and non-username prefix modes never consume this; skipping the remote probe preserves the exact branch name.\n  const username =\n    !args.branchNameOverride && settings.branchPrefix === 'git-username'\n      ? await getSshGitUsername(provider, repo.path)\n      : ''\n\n  const branchConflictSubject = args.branchNameOverride ? 'branch name' : 'worktree name'\n  // 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.\n  const basePlan = await getOrStartRemoteWorktreeCreateBasePlan(provider, repo, args.baseBranch)\n  if (!basePlan) {\n    throw new Error(\n      'Could not resolve a default base ref for this repo. Pick a base branch explicitly and try again.'\n    )\n  }\n  let { baseBranch } = basePlan\n  let { remoteTrackingBase } = basePlan\n  let baseFallback: WorktreeCreateBaseFallback | undefined\n\n  if (remoteTrackingBase) {\n    const hasRemoteTrackingBaseRef = await hasRemoteTrackingRefSsh(\n      provider,\n      repo.path,\n      remoteTrackingBase.ref\n    )\n    const hasNamedLocalBaseRef = await hasRemoteWorktreeBaseRef(provider, repo.path, baseBranch)\n    const hasFallbackLocalBaseRef =\n      !hasNamedLocalBaseRef &&\n      (await hasRemoteWorktreeBaseRef(provider, repo.path, remoteTrackingBase.branch))\n    if (!hasRemoteTrackingBaseRef && (hasNamedLocalBaseRef || hasFallbackLocalBaseRef)) {","sourceCodeStart":1498,"sourceCodeEnd":1534,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/worktree-remote.ts#L1498-L1534","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass an explicit args.baseBranch (e.g. the repo's real default) so the resolver never has to guess.","Verify the remote repo actually exposes its default branch ref (register roots, then list refs).","Configure the repo's default branch in Orca settings so future creates resolve automatically."],"exampleFix":"// before\nconst basePlan = await getOrStartRemoteWorktreeCreateBasePlan(provider, repo, args.baseBranch)\nif (!basePlan) {\n  throw new Error('Could not resolve a default base ref for this repo. Pick a base branch explicitly and try again.')\n}\n\n// after — surface candidates so the UI can prefill the prompt\nif (!basePlan) {\n  const candidates = await listRemoteDefaultBranchCandidates(provider, repo.path)\n  throw new BaseRefUnresolvedError(candidates)\n}","handlingStrategy":"validation","validationCode":"// Resolve a base before create; prompt the user if none is found\nlet base = args.baseBranch ?? store.getRepoDefaultBranch(repo.id)\nif (!base) {\n  const candidates = await listRemoteDefaultBranchCandidates(provider, repo.path)\n  if (candidates.length === 0) {\n    return { ok: false, error: 'No default base branch found. Pick one explicitly.' }\n  }\n  base = await promptUserForBaseBranch(candidates)\n}","typeGuard":null,"tryCatchPattern":"catch (err) {\n  if (err instanceof Error && err.message.startsWith('Could not resolve a default base ref')) {\n    openBaseBranchPicker(repo)\n  } else { throw err }\n}","preventionTips":["Always pass an explicit baseBranch when the repo's default is non-standard.","Prefetch the base plan (prefetchRemoteWorktreeCreateBase) so the create flow knows early whether a default exists.","Set the repo's default branch in Orca settings to avoid the resolver guessing."],"tags":["worktree-create","base-ref","ssh","remote","git"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}