Skip to content

gh pr create from one remote to other remote #1985

Open

Description

@zemse

CLI Feedback

You can use this template to give us structured feedback or just wipe it and leave us a note. Thank you!

What have you loved?

colors are so cool

What was confusing or gave you pause?

creating a pr from one remote to other remote.

Are there features you'd like to see added?

If I could specify exact branch on my fork, to exact branch on remote, it'd be great:

$ gh pr create fork/master upstream/master

or

$ gh pr create fork/abc upstream/egf

Anything else?

thanks for creating this!

Activity

  1. vilmibm commented on Oct 22, 2020

    @vilmibm
    Contributor

    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 headBranch will do the correct thing.

    Do you need to perform this on non-local branches, though?

  2. added
    more-info-needed
    on Oct 22, 2020
  3. zemse commented on Oct 23, 2020

    @zemse
    Author

    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.

    gh pr create fork/proposed-changes-for-friend fork-of-my-friend/fix-another-bug
    

    Also, if I have write access to friend's repo, could I make a PR instead?

    gh pr create fork-of-my-friend/fix-another-bug upstream/dev
    
  4. mislav commented on Oct 27, 2020

    @mislav
    Contributor

    @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?

  5. zemse commented on Oct 27, 2020

    @zemse
    Author
    $ gh pr create -R friend-username/repo-name -H my-username:branch-name
    

    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.

    $ gh pr create -B remotes/upstream/dev -H remotes/fork/new-feature
    

    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.

    $ gh pr create -B OrgName/repo-name/branch-name -H UserName/repo-name/branch-name
    
  6. added
    enhancement
    needs-design
    and removed
    more-info-needed
    on Dec 16, 2020
  7. GMNGeoffrey commented on Dec 30, 2020

    @GMNGeoffrey

    +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.

  8. mislav commented on Jan 18, 2021

    @mislav
    Contributor

    @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.

  9. GMNGeoffrey commented on Jan 19, 2021

    @GMNGeoffrey

    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.

  10. added and removed
    needs-design
    enhancement
    on Mar 16, 2022
  11. darcyclarke commented on Mar 16, 2022

    @darcyclarke

    Actions

    • we'll improve our documentation around owner branch syntax & base repo (ie. -R & from:to)
  12. added
    gh-pr
    on Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsgh-pr

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions