jesseduffield/lazygit · error
A remote named '%s' does not exist
Error message
A remote named '%s' does not exist
What it means
BranchesController.promptForTargetBranchNameAndCreatePullRequest (pkg/gui/controllers/branches_controller.go) looks up the requested remote in the already-loaded Model().Remotes via lo.NoneBy; when no remote with that name exists it surfaces the translated NoValidRemoteName string ('A remote named %s does not exist'). It is a pure precondition failure: the PR target remote must already be configured in the repo.
Source
Thrown at pkg/gui/controllers/branches_controller.go:851
}
return self.createPullRequest(checkedOutBranch.UpstreamBranch, selectedBranch.UpstreamBranch)
},
},
)
menuItems = append(menuItems, menuItemsForBranch(checkedOutBranch)...)
}
menuItems = append(menuItems, menuItemsForBranch(selectedBranch)...)
return self.c.Menu(types.CreateMenuOptions{Title: fmt.Sprint(self.c.Tr.CreatePullRequestOptions), Items: menuItems})
}
func (self *BranchesController) promptForTargetBranchNameAndCreatePullRequest(fromBranch *models.Branch, toRemote string) error {
remoteDoesNotExist := lo.NoneBy(self.c.Model().Remotes, func(remote *models.Remote) bool {
return remote.Name == toRemote
})
if remoteDoesNotExist {
return fmt.Errorf(self.c.Tr.NoValidRemoteName, toRemote)
}
self.c.Prompt(types.PromptOpts{
Title: fmt.Sprintf("%s → %s/", fromBranch.UpstreamBranch, toRemote),
FindSuggestionsFunc: self.c.Helpers().Suggestions.GetRemoteBranchesForRemoteSuggestionsFunc(toRemote),
HandleConfirm: func(toBranch string) error {
self.c.Log.Debugf("PR will target branch '%s' on remote '%s'", toBranch, toRemote)
return self.createPullRequest(fromBranch.UpstreamBranch, toBranch)
},
})
return nil
}
func (self *BranchesController) createPullRequest(from string, to string) error {
url, err := self.c.Helpers().Host.GetPullRequestURL(from, to)
if err != nil {
return errView on GitHub (pinned to c477a2959b)
Solutions
- Add the remote in a terminal: git remote add <name> <url>, then press 'R' / refresh in lazygit so Model().Remotes reloads.
- Or pick the existing remote (usually origin) from the PR options menu.
- If the remote was deleted intentionally, remove stale references and refresh before retrying.
Example fix
# terminal # before: only 'origin' exists, PR targets 'upstream' git remote add upstream https://github.com/org/repo.git git fetch upstream # then refresh remotes in lazygit and retry
Defensive patterns
Strategy: validation
Validate before calling
// Guard before creating the PR prompt:
exists := false
for _, r := range remotes {
if r.Name == toRemote {
exists = true
}
}
if !exists {
return fmt.Errorf("remote %s missing; add it first", toRemote)
} Try / catch
if err := createPRToRemote(fromBranch, "upstream"); err != nil {
if strings.Contains(err.Error(), "does not exist") {
// run `git remote add` + fetch, then surface a retry affordance
}
return err
} Prevention
- Keep PR-target remotes (origin, upstream) configured before starting fork workflows.
- Refresh remotes in lazygit after changing them on the command line.
When it happens
Trigger: Invoking the create-PR flow targeting a remote name that is not in git's remote list — e.g. choosing 'upstream' when only 'origin' is configured, or a remote deleted from .git/config while lazygit still shows a stale model.
Common situations: Fork workflows where the user selects the wrong remote in the PR-options menu; the remote was renamed or removed outside lazygit without a refresh; typos when a custom remote name is expected.
Related errors
- Cannot open a pull request for a branch with no upstream
- This branch doesn't exist on remote. You need to push it to
- No pull request found for this branch
- unsupported or invalid remote URL: %s
- Git version must be at least %s. Please upgrade your git ver
AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15).
Data as JSON: /api/errors/c23d24e1b73a0c75.
Report an issue: GitHub.