cli: `pr checkout` assumes wrong git remote as the base repository
$ ~/Downloads/gh_0.5.4_macOS_amd64/bin/gh --version
gh version 0.5.4 (2020-02-04)
https://github.com/cli/cli/releases/tag/v0.5.4
Steps to reproduce the behavior
From my clone of the sympy/sympy repo I tried to clone PR 18646
$ ~/Downloads/gh_0.5.4_macOS_amd64/bin/gh pr checkout 18646
graphql error: 'Could not resolve to a PullRequest with the number of 18646.'
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 8
- Comments: 21 (10 by maintainers)
@PowerKiKi Since
jbox-web/redmine_git_hosting
is a fork,gh pr checkout 123
in that repo will try to check out PR#123
of the parent repository. This might not be what you wanted.We might change this default, but until then, the only workaround you can do is:
gh should not assume the “upstream” style of remote management. I personally think the “
origin
is upstream,<username>
for forks (including your own)” is much better, and there are a lot of people who do it that way.In case someone else runs into this like I did, If you open
.git/config
you’ll see the linegh-resolved = base
. Move that line to the remote you want and it will now use it as the base.gh version 1.10.3 (2021-05-21)
git push --set-upstream origin master
after the fix.Saw this the other day, realized my gh version was ancient, upgraded and it worked… asked me which repo to use.
Today I got the error again. Do I need to tell it to re-prompt me somehow?
using the url option worked fine.
I can confirm that this is no longer an issue for me too, because it now ask which remote to use.
This issue should be closed.
I don’t think this issue is still happening. I have a fork of cli/cli and when I ran the command:
It asked me which should be my base repository. 🤔
Version details:
Correct,
jbox-web/redmine_git_hosting
is a fork (of a fork of a fork of a fork, believe or not !). But it has now outlived all ancestors (by far), and it should be considered as an independent project by now. But of course there is no way forcli/cli
to know that.What would be super useful, if this cannot be fixed easily, is to have a slightly more verbose message including the repository that was assumed. I tried
--debug
,--verbose
flags to no avail. Something like: