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 err

View on GitHub (pinned to c477a2959b)

Solutions

  1. Add the remote in a terminal: git remote add <name> <url>, then press 'R' / refresh in lazygit so Model().Remotes reloads.
  2. Or pick the existing remote (usually origin) from the PR options menu.
  3. 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

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


AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15). Data as JSON: /api/errors/c23d24e1b73a0c75. Report an issue: GitHub.