cli / cli/cli

could not resolve remote "origin": none of the git remotes configured for this repository correspond to the `GH_HOST` environment variable.

Open
#10,891 14 comments 1 reaction 0 assignees View on GitHub
bug gh-pr more-info-needed needs-triage
Dominant language
Go
Stars
46.3k
Forks
9k
Avg merge
2d 9h
Merged PRs (30d)
89

Description

### Describe the bug

When using GH_HOST, GH_REPO, and GH_ENTERPRISE_TOKEN in conjunction with `gh pr create`, it started failing about a week ago for us, and we can't reproduce as a human (even with a token) or determine any glaring differences between the CI/CD and local invocations of the same tool, nor even with any version bumps since the last working version (~even if we downgrade to 2.70.0, it still fails now~ 2.70.0 still works actually).

```
could not resolve remote "origin": none of the git remotes configured for this repository correspond to the GH_HOST environment variable. Try adding a matching remote or unsetting the variable
```

Some of the settings/troubleshooting attempts

```
GH_HOST=our.enterprise.host
GH_REPO=out.enterprise.host/ourorg/ourrepo
GH_ENTERPRISE_TOKEN=
GH_DEBUG=true

00:00:45 + git remote -v
00:00:45 origin git@our.enterprise.host:ourorg/ourrepo (fetch)
00:00:45 origin git@our.enterprise.host:ourorg/ourrepo (push)
00:00:45 + git version
00:00:45 git version 2.43.5
00:00:45 + gh version
00:00:45 gh version 2.71.2 (2025-04-24)
00:00:45 + git config --get-regexp '^branch\.autoupdate/20250428-183455\.(remote|merge|pushremote|gh-merge-base)$'
00:00:45 branch.autoupdate/20250428-183455.remote origin
00:00:45 branch.autoupdate/20250428-183455.merge refs/heads/autoupdate/20250428-183455
00:00:45 + git rev-parse --symbolic-full-name 'autoupdate/20250428-183455@{push}'
00:00:45 refs/remotes/origin/autoupdate/20250428-183455
```

and invocation

```
00:00:45 + gh pr create --label autoupdate-server_admap --title '[autoupdate][20250428-183455] Update files from source folder' --body 'This PR is a result of script, which auto update files from the source directory.'
00:00:45 [git remote -v]
00:00:45 [git config --get-regexp ^remote\..*\.gh-resolved$]
00:00:45 * Request at 2025-04-28 18:34:59.675488605 +0000 UTC m=+0.085715954
00:00:45 * Request to https://our.enterprise.host/api/graphql
00:00:46 * Request took 245.740739ms
00:00:46 [git status --porcelain]
00:00:46 [git symbolic-ref --quiet HEAD]
00:00:46 [git config --get-regexp ^branch\.autoupdate/20250428-183455\.(remote|merge|pushremote|gh-merge-base)$]
00:00:46 [git rev-parse --symbolic-full-name autoupdate/20250428-183455@{push}]
00:00:46 could not resolve remote "origin": none of the git remotes configured for this repository correspond to the GH_HOST environment variable. Try adding a matching remote or unsetting the variable

```

### Affected version

Please run `gh version` and paste the output below.

```
gh version 2.71.2 (2025-04-24)
```

### Steps to reproduce the behavior

1. Have an enterprise server
2. Set the GH_HOST, GH_REPO, GH_ENTERPRISE_TOKEN appropriately
3. Have an origin with ssh-formatted location (not quite URL but git@ style)

### Expected vs actual behavior

A PR should be created (and was up until a week ago); the error regarding inability to find the origin is output and a failure rc is returned.

### Logs

See invocation above

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.