You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gh pr create from one remote to other remote #1985
The creation logic you requested is possible, albeit a little confusing. If your current branch is already set to track a fork, gh pr create -RupstreamOwner/upstreamName headBranch will do the correct thing.
Do you need to perform this on non-local branches, though?
To clarify, in the senario we have: a local cloned repo, a fork in github profile and a main repo. I want to forget local cloned repo, just want to use gh to do stuff between two remotes which I have access to (probably only having write access to fork and read access to main repo is sufficient).
There are multiple people who push to my fork (given access to my friends), so maybe my local cloned repo might not be updated, though I have no problem updating it. But when I use gh I think it like it's github right in my terminal, so at least in this case, I feel if I could make a PR through website without making my local branch up to date, I could be able to do same with gh.
Now the PR which I want to make is a bit weird: I have fix-some-bug branch on my fork and the destination I want to be is dev branch on the main repo instead of standard same branch to same branch.
In that fashion, using github website, it's more of mouse/trackpad clicks which I am slow at, but with keyboard it'd be cool to do something clear like:
gh pr create fork/fix-some-bug upstream/dev
Assuming that I already have remotes fork and upstream.
Also, I could have three remotes, like an additional remote as fork-of-my-friend to which I'd like to push to occasionally, but my friend isn't online to give me push access, so I want to make a PR to his/her repo, and then he/she can take care of it later whenever they're back.
@zemse Thanks for explaining your use case in detail!
Right now, the way to achieve what you are looking for is using the syntax that @vilmibm described above (ideally, after having had pushed the branch to the right remote). However, if I'm understanding your preferred usage as illustrated in your comment, you would prefer to use remote tracking branches (e.g. remote/branchname) as an alternate syntax for referring to a specific repository?
However, the syntax for both source and destination is a bit different so it's more likely I'll forget it and need to refer to docs again. I mean if API to do this is a bit symmetric, it would be helpful.
@mislav Yeah, having this work with the traditional git branches syntax could be intuitive.
+1 on supporting remote name syntax. It's a bit weird to have to use a totally different syntax to specify the remote when dealing with gh. It especially makes it hard to script around it.
@GMNGeoffrey Regarding your workaround in the iree repo: I can see how extracting the owner portion from a git remote is tricky. However, I think you did not have to specify --head for the pull request at all. Since you've pushed the branch manually, gh should auto-detect which remote the current branch was pushed to. Maybe it makes your script simpler.
I agree it should work without a head branch specified, but I've found that it frequently doesn't. I think I originally added the specific head branch because of #1820, but since then I've had other issues where it can't detect the head branch correctly, which I think is #575.
Activity
vilmibm commentedon Oct 22, 2020
Thanks for the feedback!
The creation logic you requested is possible, albeit a little confusing. If your current branch is already set to track a fork,
gh pr create -RupstreamOwner/upstreamName headBranchwill do the correct thing.Do you need to perform this on non-local branches, though?
zemse commentedon Oct 23, 2020
To clarify, in the senario we have: a local cloned repo, a fork in github profile and a main repo. I want to forget local cloned repo, just want to use
ghto do stuff between two remotes which I have access to (probably only having write access to fork and read access to main repo is sufficient).There are multiple people who push to my fork (given access to my friends), so maybe my local cloned repo might not be updated, though I have no problem updating it. But when I use
ghI think it like it's github right in my terminal, so at least in this case, I feel if I could make a PR through website without making my local branch up to date, I could be able to do same withgh.Now the PR which I want to make is a bit weird: I have
fix-some-bugbranch on my fork and the destination I want to be isdevbranch on the main repo instead of standard same branch to same branch.In that fashion, using github website, it's more of mouse/trackpad clicks which I am slow at, but with keyboard it'd be cool to do something clear like:
Assuming that I already have remotes
forkandupstream.Also, I could have three remotes, like an additional remote as
fork-of-my-friendto which I'd like to push to occasionally, but my friend isn't online to give me push access, so I want to make a PR to his/her repo, and then he/she can take care of it later whenever they're back.Also, if I have write access to friend's repo, could I make a PR instead?
mislav commentedon Oct 27, 2020
@zemse Thanks for explaining your use case in detail!
Right now, the way to achieve what you are looking for is using the syntax that @vilmibm described above (ideally, after having had pushed the branch to the right remote). However, if I'm understanding your preferred usage as illustrated in your comment, you would prefer to use remote tracking branches (e.g.
remote/branchname) as an alternate syntax for referring to a specific repository?zemse commentedon Oct 27, 2020
I tried this and it works! Thanks!
However, the syntax for both source and destination is a bit different so it's more likely I'll forget it and need to refer to docs again. I mean if API to do this is a bit symmetric, it would be helpful.
@mislav Yeah, having this work with the traditional git branches syntax could be intuitive.
Or if github usernames are acceptable, that is also great as it won't involving adding a remote for doing stuff that is on GitHub not on my machine.
GMNGeoffrey commentedon Dec 30, 2020
+1 on supporting remote name syntax. It's a bit weird to have to use a totally different syntax to specify the remote when dealing with
gh. It especially makes it hard to script around it.Get remote name in a more portable way in gh scripting (#4357)
Get remote name in a more portable way in gh scripting (iree-org#4357)
mislav commentedon Jan 18, 2021
@GMNGeoffrey Regarding your workaround in the
ireerepo: I can see how extracting the owner portion from a git remote is tricky. However, I think you did not have to specify--headfor the pull request at all. Since you've pushed the branch manually, gh should auto-detect which remote the current branch was pushed to. Maybe it makes your script simpler.GMNGeoffrey commentedon Jan 19, 2021
I agree it should work without a head branch specified, but I've found that it frequently doesn't. I think I originally added the specific head branch because of #1820, but since then I've had other issues where it can't detect the head branch correctly, which I think is #575.
darcyclarke commentedon Mar 16, 2022
Actions
-R&from:to)