Repository navigation
Description
Describe the bug
For boring work-related reasons, my git's remote."origin".url goes through a proxy, so the shape of the remote URL is not simply https://github.com/owner/repo.
This breaks things like gh pr view, because gh is unable to deduce the Github URL of my repo.
Affected version
$ gh version
gh version 2.88.1 (2026-03-12)
https://github.com/cli/cli/releases/tag/v2.88.1Steps to reproduce the behavior
First, assume that my .git/config contains this: (i could reproduce my issue by simply git init a repo on my local machine and adding that config)
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://weird-proxy.com/github/owner/repo
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
pushRemote = origin
[branch "some-feature-branch"]
pushRemote = originAssume also that this really corresponds to a repo https://github.com/owner/repo hosted on Github. I'd like gh commands to work. For example:
$ gh browse # fails
unable to determine base repository: none of the git remotes configured for this repository point to a known GitHub host. To tell gh about a new GitHub host, please use `gh auth login`
$ GH_REPO=owner/repo gh browse # works!
$ GH_REPO=owner/repo gh pr list --state all # works!Now, i jump over to a feature branch some-feature-branch. I want to open a PR:
$ GH_REPO=owner/repo gh pr create
could not resolve remote "origin": none of the git remotes configured for this repository point to a known GitHub host. To tell gh about a new GitHub host, please use `gh auth login`
$ gh repo set-default toothbrush/SeeKee # just a random example repo that exists in reality
none of the git remotes configured for this repository point to a known GitHub host. To tell gh about a new GitHub host, please use `gh auth login`At this point i'd expect gh to respect GH_REPO and go from there, but it seems it doesn't. Somewhere #2300 i saw a reference to gh-resolved, but that also doesn't help in my case.
git config --local "remote.origin.gh-resolved" https://github.com/owner/repo
Expected vs actual behavior
I'd expect a flag or env var that I could set, to force gh to use a given Github repo as the target for my operations.
I could also imagine offering some kind of repo-local config flag (a bit like gh-resolved) to tell gh specifically what Github repo a remote corresponds to. E.g., in .git/config:
[remote "origin"]
url = https://weird-proxy.com/github/owner/repo
gh-repo-url = https://github.com/toothbrush/foo
fetch = +refs/heads/*:refs/remotes/origin/*
This way i could configure a weird proxy for my own push/pull actions, but still benefit from gh operations.
Activity
williammartin commentedon Mar 26, 2026
Thanks for the detailed writeup. Just trying to understand your set up here, do you do
gh auth loginand if so where do you target? Or do you setGH_HOSTandGH_TOKEN? What URL does your API endpoint live at (https://weird-proxy.com/github/api/v3?`), or is this proxy only a git proxy and the API lives elsewhere?toothbrush commentedon Mar 27, 2026
Yep good questions. I still expect API things to run directly against regular Github, so indeed i would just:
I do not have
GH_HOSTorGH_TOKENset – i tried usingGH_HOSTin my weirdly-configured project to forceghto use normal Github.com, but that failed because then it filters out origins that don't look like normal Github.com and fails.The proxy is indeed only for Git push & pull. The commits end up on Github.com and we continue to use Github.com for PRs and so on, but i'd like to be able to use the
ghtool, too.toothbrush commentedon Mar 27, 2026
As a discussion starter, i made a patch that solves my issue. I don't know if it's a desirable approach.
I was able to
git config remote.origin.gh-repo-url [email protected]:owner/repo.gitand haveghperform operations against the Github repo i intend.github-actions commentedon Mar 30, 2026
Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.
Unless you see the help wantedContributions welcome
label, we are not currently looking for external contributions for this feature.
If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.