goreleaser/goreleaser · error
unable to get upstream's remote while qualifying relative re
Error message
unable to get upstream's remote while qualifying relative remote: %w
What it means
After resolving the upstream branch name, extractRelativeRepoFromConfig runs `git config --get branch.<upstream>.remote`; failure here is wrapped with this message. It means the upstream branch name was found but its remote mapping is missing from git config.
Source
Thrown at internal/git/config.go:45
}
// This is a relative remote URL and requires some additional processing
if out == "." {
return extractRelativeRepoFromConfig(ctx)
}
return ExtractRepoFromURL(out)
}
func extractRelativeRepoFromConfig(ctx context.Context) (result config.Repo, err error) {
out, err := Clean(Run(ctx, "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"))
if err != nil {
return result, fmt.Errorf("unable to get upstream while qualifying relative remote: %w", err)
}
if out == "" {
return result, errors.New("unable to get upstream while qualifying relative remote: empty output")
}
out, err = Clean(Run(ctx, "config", "--get", fmt.Sprintf("branch.%s.remote", out)))
if err != nil {
return result, fmt.Errorf("unable to get upstream's remote while qualifying relative remote: %w", err)
}
if out == "" {
return result, errors.New("unable to get upstream's remote while qualifying relative remote: empty output")
}
out, err = Clean(Run(ctx, "ls-remote", "--get-url", out))
if err != nil {
return result, fmt.Errorf("unable to get upstream while qualifying relative remote: %w", err)
}
return ExtractRepoFromURL(out)
}
func ExtractRepoFromURL(rawurl string) (config.Repo, error) {
// removes the .git suffix and any new lines
s := strings.TrimSuffix(strings.TrimSpace(rawurl), ".git")
// if the URL contains a :, indicating a SSH config,
// remove all chars until it, including itself
// on HTTP and HTTPS URLs it will remove the http(s): prefix,View on GitHub (pinned to f5edd73956)
Solutions
- Set the remote mapping: `git branch --set-upstream-to=origin/<branch>` which writes branch.<name>.remote
- Inspect `git config --get-regexp '^branch\.'` and repair missing remote/merge entries
- Re-clone or restore a valid .git/config if it was hand-edited
- Configure a fallback remote resolution (use `origin`) when branch.*.remote is absent
Example fix
// .git/config before
[branch "feature"]
merge = refs/heads/feature
// after
[branch "feature"]
remote = origin
merge = refs/heads/feature Defensive patterns
Strategy: validation
Validate before calling
branch, _ := exec.Command("git", "rev-parse", "--abbrev-ref", "HEAD").Output()
remote := exec.Command("git", "config", "--get", "branch."+strings.TrimSpace(string(branch))+".remote")
if err := remote.Run(); err != nil { /* repair config first */ } Type guard
func isMissingBranchRemote(err error) bool {
return strings.Contains(err.Error(), "unable to get upstream's remote")
} Try / catch
repo, err := git.ExtractRepoFromConfig(ctx)
if err != nil && strings.Contains(err.Error(), "unable to get upstream's remote") {
exec.Command("git", "branch", "--set-upstream-to=origin/"+branch).Run()
repo, err = git.ExtractRepoFromConfig(ctx)
} Prevention
- Use `git branch --set-upstream-to` instead of hand-editing .git/config
- Keep remote and merge keys paired under each [branch] section
- Audit configs after migrations or repo restructuring
- Run `git config --list` sanity checks in setup scripts
When it happens
Trigger: Upstream exists symbolically but `branch.<name>.remote` is absent — e.g. hand-edited .git/config, upstream set to a local branch name rather than a remote-tracking branch, or partial config migration.
Common situations: Configs created by tools that set branch.merge without branch.remote, repos where .git/config was stripped, branches tracking other local branches instead of remote refs.
Related errors
- unable to get upstream while qualifying relative remote: %w
- failed to apply template %s: %w
- globbing failed for pattern %s: %w
- failed to parse %s: %w
- git: failed to template private key: %w
AI-assisted analysis of goreleaser/goreleaser@f5edd73956 (2026-09-05).
Data as JSON: /api/errors/2b64b7d04f76ec25.
Report an issue: GitHub.