jesseduffield/lazygit · error
Remote {{.remoteName}} already exists and has different URL
Error message
Remote {{.remoteName}} already exists and has different URL What it means
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.
Source
Thrown at pkg/gui/controllers/remotes_controller.go:189
}
}
// Fetch the remote
return self.fetchAndCheckout(self.c.Contexts().Remotes.GetSelected(), branchToCheckout)
},
})
return nil
}
// Ensures the fork remote exists (matching the given URL).
// If it exists and matches, it’s selected and fetched; otherwise, it’s created and then fetched and checked out.
// If it does exist but with a different URL, an error is returned.
func (self *RemotesController) ensureForkRemoteAndCheckout(remoteName string, remoteUrl string, branchToCheckout string) error {
for idx, remote := range self.c.Model().Remotes {
if remote.Name == remoteName {
hasTheSameUrl := slices.Contains(remote.Urls, remoteUrl)
if !hasTheSameUrl {
return errors.New(utils.ResolvePlaceholderString(
self.c.Tr.IncompatibleForkAlreadyExistsError,
map[string]string{
"remoteName": remoteName,
},
))
}
self.c.Contexts().Remotes.SetSelection(idx)
return self.fetchAndCheckout(remote, branchToCheckout)
}
}
return self.addAndCheckoutRemote(remoteName, remoteUrl, branchToCheckout)
}
func (self *RemotesController) add() error {
self.c.Prompt(types.PromptOpts{
Title: self.c.Tr.NewRemoteName,
HandleConfirm: func(remoteName string) error {
self.c.Prompt(types.PromptOpts{View on GitHub (pinned to c477a2959b)
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.
Example fix
# before $ git remote -v fork git@github.com:someone/other-repo.git (fetch) # after $ git remote set-url fork https://github.com/you/your-fork.git
Defensive patterns
Strategy: validation
Validate before calling
func remoteMatchesUrl(remote *models.Remote, url string) bool {
return slices.Contains(remote.Urls, url)
}
// before fork flow: ensure remoteMatchesUrl or remote absent Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- This branch doesn't exist on remote. You need to push it to
- unsupported or invalid remote URL: %s
- Git version must be at least %s. Please upgrade your git ver
- Lazygit does not support bare repos.
- unexpected git output
AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15).
Data as JSON: /api/errors/dfc663923b77dbf4.
Report an issue: GitHub.