stablyai/orca · error
Could not find an available remote name for ${preferred}.
Error message
Could not find an available remote name for ${preferred}. What it means
Thrown by ensureUniqueRemoteName when the preferred git remote name and all suffixed variants (preferred-2 through preferred-99) already exist in the repository's remote list. The function lists existing remotes via `git remote`, and only after exhausting 98 candidate names does it give up. This is a guard against flooding a repo with colliding remote names during automated worktree push-target setup.
Source
Thrown at src/main/ipc/worktree-push-target-setup.ts:69
preferred: string
): Promise<string> {
const { stdout } = await execGit(['remote'], repoPath)
const existing = new Set(
stdout
.split(/\r?\n/)
.map((line) => line.trim())
.filter(Boolean)
)
if (!existing.has(preferred)) {
return preferred
}
for (let suffix = 2; suffix < 100; suffix += 1) {
const candidate = `${preferred}-${suffix}`
if (!existing.has(candidate)) {
return candidate
}
}
throw new Error(`Could not find an available remote name for ${preferred}.`)
}
// Exported for unit tests: the `execGit` seam drives the remote add/reuse/fetch
// behavior without a real repo. `isRemoteCreatedByKnownWorktree` lets the caller
// inject the store-aware ownership decision for the reuse case.
export async function prepareWorktreePushTargetWithExec(
execGit: GitRemoteExec,
repoPath: string,
target: GitPushTarget,
isRemoteCreatedByKnownWorktree: (existingRemote: string) => boolean
): Promise<GitPushTarget> {
const { remoteCreated: _ignoredRemoteCreated, ...sanitizedTarget } = target
let remoteName = target.remoteName
let remoteCreated = false
if (target.remoteUrl) {
const existingRemote = await findRemoteForUrl(execGit, repoPath, target.remoteUrl)
if (existingRemote) {
remoteName = existingRemoteView on GitHub (pinned to 1136503c6a)
Solutions
- Remove stale/unused remotes with `git remote remove <name>` to free up the namespace, then retry.
- Choose a different preferred name that does not collide.
- If this is expected for your workflow, raise the suffix ceiling or implement a UUID-suffixed fallback in a wrapper.
Defensive patterns
Strategy: validation
Validate before calling
const existing = (await execGit(['remote'], repoPath)).stdout.split(/\r?\n/).filter(Boolean)
if (existing.length > 90) {
// warn or clean up stale remotes before attempting ensureUniqueRemoteName
} Try / catch
try {
remoteName = await ensureUniqueRemoteName(execGit, repoPath, preferred)
} catch (e) {
if (/Could not find an available remote name/.test((e as Error).message)) {
remoteName = `${preferred}-${crypto.randomUUID().slice(0, 8)}`
} else throw e
} Prevention
- Periodically prune stale remotes created by worktree push-target setup.
- Choose a distinctive preferred name to avoid collisions.
- Warn the user when the remote count grows large, indicating cleanup is needed.
When it happens
Trigger: ensureUniqueRemoteName(execGit, repoPath, preferred) where `git remote` returns a set containing 'preferred', 'preferred-2', ..., 'preferred-99'. The loop from suffix 2..99 finds no gap, so the throw fires.
Common situations: A repo accumulated 99+ similarly-named remotes from repeated worktree/push-target setup without cleanup. An automation loop kept adding remotes. A migration/import created many colliding remotes. Realistically this indicates stale-remote accumulation that should be cleaned.
Related errors
- No worktrees on environment ${envName}
- No worktrees on environment ${envName}
- normalizeGitErrorMessage(error, 'push')
- normalizeGitErrorMessage(error, 'push')
- normalizeGitErrorMessage(error, 'pull')
AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12).
Data as JSON: /api/errors/544acd7b829963d4.
Report an issue: GitHub.