{"record":{"id":"0c500e38fbbfbd84","repo":"gitbutlerapp/gitbutler","slug":"remote-sameurlremote-name-with-url-sameurlremote-url-already","errorCode":null,"errorMessage":"Remote ${sameUrlRemote.name} with url ${sameUrlRemote.url} already exists.","messagePattern":"Remote (.+?) with url (.+?) already exists\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/desktop/src/lib/git/remotesService.ts","lineNumber":29,"sourceCode":"export class RemotesService {\n\tconstructor(private backend: IBackend) {}\n\tasync remotes(projectId: string) {\n\t\treturn await this.backend.invoke<GitRemote[]>(\"list_remotes\", { projectId });\n\t}\n\n\tasync addRemote(projectId: string, name: string, url: string) {\n\t\tconst remotes = await this.remotes(projectId);\n\n\t\tconst sameNameRemote = remotes.find((remote) => remote.name === name);\n\t\tif (sameNameRemote) {\n\t\t\tthrow new Error(`Remote with name ${sameNameRemote.name} already exists.`);\n\t\t}\n\n\t\tconst sameUrlRemote = remotes.find((remote) => remote.url === url);\n\t\tif (sameUrlRemote) {\n\t\t\t// This should not happen, and indicates we are incorrectly showing an \"apply from fork\"\n\t\t\t// button in the user interface.\n\t\t\tthrow new Error(`Remote ${sameUrlRemote.name} with url ${sameUrlRemote.url} already exists.`);\n\t\t}\n\n\t\treturn await this.backend.invoke<string>(\"add_remote\", { projectId, name, url });\n\t}\n}\n","sourceCodeStart":11,"sourceCodeEnd":35,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/apps/desktop/src/lib/git/remotesService.ts#L11-L35","documentation":"Thrown by remotesService.addRemote when a remote with the same URL already exists, even under a different name. The comment in the code notes this should not happen normally and indicates the UI incorrectly showed an 'apply from fork' button for a project that already has this remote. It's a guard against duplicate remotes pointing at the same URL.","triggerScenarios":"Calling addRemote(projectId, name, url) where some existing remote already has the exact same url, typically via an 'apply from fork' UI action.","commonSituations":"UI state out of sync with the actual git remote list — fork already applied under another name; adding the same fork to two stacks; stale remote list cache.","solutions":["Refresh the remote list before offering the 'apply from fork' action so already-added URLs don't produce the button.","If the URL already exists, reuse the existing remote instead of adding a new one.","Catch the error in the UI and inform the user the fork remote is already configured."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const remotes = await remotesService.remotes(projectId);\nif (remotes.some(r => r.url === url)) return; // already added; reuse it","typeGuard":null,"tryCatchPattern":"try {\n  await remotesService.addRemote(projectId, name, url);\n} catch (e) {\n  if (String(e).includes('with url')) showToast('This fork is already added');\n}","preventionTips":["Refresh the remote list before showing 'apply from fork' buttons","Deduplicate by URL when syncing fork state with the UI"],"tags":["git","remote","duplicate"],"backgroundTag":"file-already-exists","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}