cli / cli

GitHub’s official command line tool
https://cli.github.com
MIT License
37k stars 5.69k forks source link

`gh repo set-default` should gain an option for passing a Git remote name #8304

Closed jwodder closed 11 months ago

jwodder commented 11 months ago

Describe the feature or problem you’d like to solve

Sometimes, I need to run gh repo set-default in a local clone of a forked repository where the clone has two Git remotes — one tracking the fork, one tracking the fork's parent. Currently, I have to type out the {owner}/{name} value for the repo I want to choose, which (when I'm not selecting a repository I own) usually involves first looking it up by running git remote -v. I'd find it much more convenient if I could instead just specify the name of the Git remote that points to the repository (e.g., "origin" or "upstream" or whatever).

Proposed solution

Give gh repo set-default a --remote option that takes the name of a Git remote of the local repository and sets the default to the GitHub repository that that remote points to.

samcoe commented 11 months ago

@jwodder Appreciate you sharing your experience. We have received various forms of this request and have been using https://github.com/cli/cli/issues/1481 to collect them. I understand that https://github.com/cli/cli/issues/1481 is slightly different than what you are suggesting, but very related as repo set-default is tangental to specifying the --repo for most commands. I am going to close this for now and we will make sure to address this if/when we address https://github.com/cli/cli/issues/1481.