{"record":{"id":"dfc663923b77dbf4","repo":"jesseduffield/lazygit","slug":"remote-remotename-already-exists-and-has-diff","errorCode":null,"errorMessage":"Remote {{.remoteName}} already exists and has different URL","messagePattern":"Remote (.+?)\\} already exists and has different URL","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/gui/controllers/remotes_controller.go","lineNumber":189,"sourceCode":"\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Fetch the remote\n\t\t\treturn self.fetchAndCheckout(self.c.Contexts().Remotes.GetSelected(), branchToCheckout)\n\t\t},\n\t})\n\treturn nil\n}\n\n// Ensures the fork remote exists (matching the given URL).\n// If it exists and matches, it’s selected and fetched; otherwise, it’s created and then fetched and checked out.\n// If it does exist but with a different URL, an error is returned.\nfunc (self *RemotesController) ensureForkRemoteAndCheckout(remoteName string, remoteUrl string, branchToCheckout string) error {\n\tfor idx, remote := range self.c.Model().Remotes {\n\t\tif remote.Name == remoteName {\n\t\t\thasTheSameUrl := slices.Contains(remote.Urls, remoteUrl)\n\t\t\tif !hasTheSameUrl {\n\t\t\t\treturn errors.New(utils.ResolvePlaceholderString(\n\t\t\t\t\tself.c.Tr.IncompatibleForkAlreadyExistsError,\n\t\t\t\t\tmap[string]string{\n\t\t\t\t\t\t\"remoteName\": remoteName,\n\t\t\t\t\t},\n\t\t\t\t))\n\t\t\t}\n\t\t\tself.c.Contexts().Remotes.SetSelection(idx)\n\t\t\treturn self.fetchAndCheckout(remote, branchToCheckout)\n\t\t}\n\t}\n\treturn self.addAndCheckoutRemote(remoteName, remoteUrl, branchToCheckout)\n}\n\nfunc (self *RemotesController) add() error {\n\tself.c.Prompt(types.PromptOpts{\n\t\tTitle: self.c.Tr.NewRemoteName,\n\t\tHandleConfirm: func(remoteName string) error {\n\t\t\tself.c.Prompt(types.PromptOpts{","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/controllers/remotes_controller.go#L171-L207","documentation":"Returned by RemotesController.ensureForkRemoteAndCheckout when a remote with the fork's name already exists but none of its URLs match the fork URL (slices.Contains(remote.Urls, remoteUrl) is false). Rather than silently re-pointing an existing remote, lazygit refuses because the name collision may refer to a different repository.","triggerScenarios":"Using the 'fork' flow (create/open fork) where remoteName already exists in Model().Remotes with different URLs — e.g. 'origin' or the fork name already pointing at another clone URL (https vs ssh, or someone else's fork).","commonSituations":"Remote was renamed or hand-added with an SSH URL while the fork flow uses HTTPS (or vice versa); a same-named remote from a previous fork attempt; corporate mirrors where URLs get rewritten.","solutions":["Run 'git remote set-url <remoteName> <forkUrl>' so the existing remote matches the fork, then retry.","Remove the conflicting remote (remotes panel) and let the fork flow re-create it.","If both remotes are legitimately needed, rename one before retrying the fork flow."],"exampleFix":"# before\n$ git remote -v\nfork  git@github.com:someone/other-repo.git (fetch)\n\n# after\n$ git remote set-url fork https://github.com/you/your-fork.git","handlingStrategy":"validation","validationCode":"func remoteMatchesUrl(remote *models.Remote, url string) bool {\n    return slices.Contains(remote.Urls, url)\n}\n// before fork flow: ensure remoteMatchesUrl or remote absent","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Normalize remote URLs (ssh vs https) before comparing so equivalent URLs are not seen as conflicts.","Run 'git remote set-url' instead of deleting a colliding remote when it should be reused.","Check 'git remote -v' before using fork-creation flows."],"tags":["git","remote","fork","url-mismatch"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}