{"record":{"id":"9b9b8cfa99d4c17c","repo":"stablyai/orca","slug":"branch-branchname-already-exists-lastbranch","errorCode":null,"errorMessage":"Branch \"${branchName}\" already exists ${lastBranchConflictKind === 'local' ? 'locally' : 'on a remote'}. Pick a different ${branchConflictSubject}.","messagePattern":"Branch \"(.+?)\" already exists (.+?)\\. Pick a different (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ipc/worktree-remote.ts","lineNumber":1609,"sourceCode":"      }\n      lastBranchConflictKind = null\n    }\n    remotePath = computeRemoteWorktreePath(\n      effectiveSanitizedName,\n      repo.path,\n      worktreePathSettings,\n      {\n        useConfiguredAbsolutePath: hasRepoWorktreeBasePath(repo)\n      }\n    )\n    if (!(await remotePathExists(fsProvider, remotePath))) {\n      remotePathResolved = true\n      break\n    }\n  }\n  if (!remotePathResolved) {\n    if (lastBranchConflictKind) {\n      throw new Error(\n        `Branch \"${branchName}\" already exists ${lastBranchConflictKind === 'local' ? 'locally' : 'on a remote'}. Pick a different ${branchConflictSubject}.`\n      )\n    }\n    throw new Error(\n      `Could not find an available remote worktree path for \"${sanitizedName}\". Pick a different worktree name.`\n    )\n  }\n\n  validateWorkspaceLineageParentBeforeCreate(\n    store,\n    args.parentWorkspace,\n    worktreeWorkspaceKey(`${repo.id}::${remotePath}`)\n  )\n\n  const sparseDirectories = args.sparseCheckout\n    ? normalizeSparseDirectories(args.sparseCheckout.directories)\n    : []\n  if (args.sparseCheckout && sparseDirectories.length === 0) {","sourceCodeStart":1591,"sourceCodeEnd":1627,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/worktree-remote.ts#L1591-L1627","documentation":"Remote worktree create exhausted all candidate remote worktree paths (every path already exists) AND the last collision was caused by a pre-existing branch — locally or on a remote. lastBranchConflictKind records whether the conflicting branch was found locally or remotely; branchConflictSubject is 'branch name' when an override was given, else 'worktree name'. The message tells the user exactly which dimension to change.","triggerScenarios":"Remote create loop tries suffixed remote paths; each remotePathExists check returns true; the loop exits with remotePathResolved still false and a prior branch conflict recorded. Reached at worktree-remote.ts:1609.","commonSituations":"Reusing a worktree name whose branch already exists on origin or locally; suffix exhaustion because many numbered worktrees already occupy the paths; overriding a branch name that collides with an existing local/remote branch.","solutions":["Pick a different worktree name or branch name override so it doesn't collide with the existing local/remote branch.","Delete or rename the conflicting branch (locally: git branch -D; remotely: git push origin --delete) if it is stale.","If collisions are routine, widen the suffix range or change the naming template so the loop has more candidates."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-check branch availability on local + remote before the create loop\nconst existsLocal = await localBranchExists(repo.path, candidateBranch)\nconst existsRemote = await remoteBranchExists(provider, repo.path, candidateBranch)\nif (existsLocal || existsRemote) {\n  return { ok: false, fieldError: 'branchName', message: `Branch \"${candidateBranch}\" already exists (${existsLocal ? 'locally' : 'on a remote'}).` }\n}","typeGuard":null,"tryCatchPattern":"catch (err) {\n  if (err instanceof Error && /already exists .*locally|on a remote/.test(err.message)) {\n    suggestAlternateNames(repo, sanitizedName)\n  } else { throw err }\n}","preventionTips":["Choose unique worktree/branch names; avoid reusing names with existing local or remote branches.","Clean up stale remote branches after merging PRs.","Widen the suffix candidate range if your team reuses base names heavily."],"tags":["worktree-create","branch-conflict","ssh","remote","naming"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}