{"record":{"id":"4b795820a16ad11f","repo":"stablyai/orca","slug":"repo-has-no-configured-git-remotes","errorCode":null,"errorMessage":"Repo has no configured git remotes.","messagePattern":"Repo has no configured git remotes\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/git/repo.ts","lineNumber":849,"sourceCode":"    } catch {\n      // Fall through: branch has no explicit remote configured.\n    }\n  }\n\n  try {\n    const { stdout } = await gitExecFileAsync(['remote'], gitExecOptions(path, options))\n    const remotes = stdout\n      .split('\\n')\n      .map((line) => line.trim())\n      .filter(Boolean)\n    if (remotes.includes('origin')) {\n      return 'origin'\n    }\n    if (remotes.length === 1) {\n      return remotes[0]\n    }\n    if (remotes.length === 0) {\n      throw new Error('Repo has no configured git remotes.')\n    }\n    throw new Error(\n      `Repo has multiple remotes (${remotes.join(', ')}) and no default is configured. Set branch.<default>.remote.`\n    )\n  } catch (error) {\n    if (error instanceof Error) {\n      throw error\n    }\n    throw new Error('Failed to resolve default remote for repo.')\n  }\n}\n\nexport async function searchBaseRefs(path: string, query: string, limit = 25): Promise<string[]> {\n  return (await searchBaseRefDetails(path, query, limit)).map((entry) => entry.refName)\n}\n\nexport async function searchBaseRefDetails(\n  path: string,","sourceCodeStart":831,"sourceCodeEnd":867,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/git/repo.ts#L831-L867","documentation":"getDefaultRemote resolves the default push remote in priority order: branch.<default>.remote config → origin → the single configured remote → error. This throw fires when git remote returns an empty list — the repo has zero remotes configured, so there is no candidate to push/fetch to. The error is rethrown verbatim by the surrounding catch (only non-Error throws get rewrapped at :858).","triggerScenarios":"Calling getDefaultRemote(path, options) on a local-only repo (git init with no remote add), a fresh worktree whose parent repo has no remotes, a repo where all remotes were removed, or a corrupted .git/config that omits the [remote] sections.","commonSituations":"User opened a locally-initialised repo and tried to publish before adding a remote; a worktree was created from a repo that lost its remote config; CI cloned with --bare and no origin; a git init test fixture used without adding a remote; migration/tooling that stripped remotes during a reconfiguration.","solutions":["Add a remote before retrying: git remote add origin <url>.","If the user intended a local-only workflow, do not call getDefaultRemote — short-circuit publish/fetch UI in that case.","If the repo should have remotes, inspect .git/config for a corrupted/missing [remote] section.","In tests, add at least a dummy remote to fixtures that exercise getDefaultRemote."],"exampleFix":"// before\nconst remote = await getDefaultRemote(repoPath)\n\n// after: add a remote first when none exist\nconst remotes = await readRemotes(repoPath)\nif (remotes.length === 0) {\n  await run('git', ['remote', 'add', 'origin', repoUrl], { cwd: repoPath })\n}\nconst remote = await getDefaultRemote(repoPath)","handlingStrategy":"validation","validationCode":"import { gitExecFileAsync } from './runner'\n\nasync function repoHasAnyRemote(path: string): Promise<boolean> {\n  const { stdout } = await gitExecFileAsync(['remote'], { cwd: path })\n  return stdout.split('\\n').map((l) => l.trim()).filter(Boolean).length > 0\n}\n\nif (!(await repoHasAnyRemote(repoPath))) throw new Error('Add a remote before publishing (git remote add origin <url>).')","typeGuard":"function isNoRemotes(error: unknown): boolean {\n  return error instanceof Error && error.message === 'Repo has no configured git remotes.'\n}","tryCatchPattern":"if (!(await repoHasAnyRemote(repoPath))) {\n  await promptAddRemote(repoPath)\n}\ntry { return await getDefaultRemote(repoPath) }\ncatch (error) { if (isNoRemotes(error)) { await promptAddRemote(repoPath); return await getDefaultRemote(repoPath) } throw error }","preventionTips":["Add a remote before exercising publish/fetch flows.","Short-circuit publish UI for local-only repos instead of relying on getDefaultRemote to fail.","Inspect .git/config when a repo unexpectedly reports zero remotes."],"tags":["git","remote","config","validation"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}