Skip to content

Add documentation on using the 'base' remote #1864

Description

@jcmurray

Describe the feature or problem you’d like to solve

I have a forked repo with two remotes 'origin' and 'upstream' using the standard nomenclature as you can see here:

$ git remote -v
origin  [email protected]:jcmurray/md380tools.git (fetch)
origin  [email protected]:jcmurray/md380tools.git (push)
upstream        [email protected]:travisgoodspeed/md380tools.git (fetch)
upstream        [email protected]:travisgoodspeed/md380tools.git (push)

If I want to see the issues I do the following and select the upstream (base) repo. All well and good and 'upstream' is now selected as the 'base' repo.

$ gh issue list
? Which should be the base repository (used for e.g. querying issues) for this directory?  [Use arrows to move, type to filter]
> travisgoodspeed/md380tools
  jcmurray/md380tools

Now, when I did this the first time I selected the wrong repo and started trying to figure out how to correct this mistake. There is no documentation that I could find that described what to do. I eventually figured out the following:

$ git config --list | grep gh-resolved
remote.upstream.gh-resolved=base
$ git config --unset  remote.upstream.gh-resolved

The base repo is set as the key value pair in the local git config and only by unsetting this key value pair could I reset the github cli 'memory' of the incorrect setting.

Proposed solution

Simply document, maybe in a FAQ, how to reset the 'base' repo config setting in github cli and avoid users having to do what I did and figure out how to fix it themselves.

Additional context

None

Activity

  1. ShubhankarKG commented on Sep 20, 2020

    @ShubhankarKG
    Contributor

    If I'm not mistaken, you can use the -R or --repo flag to specify the repo you wish to see issues from.

  2. jcmurray commented on Sep 20, 2020

    @jcmurray
    Author

    Yes, but you can't alter the 'base' aka 'default' remote that you originally chose, perhaps in error, without messing with the local git config settings. It's tedious to have to use -R / --repo when simply documenting how to fix the 'base' setting would circumvent that.

  3. mislav commented on Sep 21, 2020

    @mislav
    Contributor

    Now, when I did this the first time I selected the wrong repo and started trying to figure out how to correct this mistake. There is no documentation that I could find that described what to do. I eventually figured out the following:

    Thank you for sharing your workaround, and sorry for the lack of transparency around this! We briefly considered the possibility that someone might choose wrong, but we didn't have time to implement a solution for that for v1.0. We will definitely aim to improve this in a next release 🙇

  4. ShubhankarKG commented on Sep 21, 2020

    @ShubhankarKG
    Contributor

    I found out that this lack of prompts is going to be an issue in every command that faces the dilemma of remotes. Should gh prompt everytime? Or should there be an option that removes the "memory" part ?

  5. mislav commented on Sep 21, 2020

    @mislav
    Contributor

    @ShubhankarKG Prompting for base repo every time would quickly become exhausting, I think. Perhaps we should give users more option to control the resolution step or clear out the cache.

  6. jcmurray commented on Sep 21, 2020

    @jcmurray
    Author

    I'd agree that being continually prompted for a base repo would be a disincentive to use gh. I think a minimal resolution would need the:

    1. Ability to query the current repo's 'base' remote setting,
    2. Ability to clear the current repo's 'base' remote setting.

    Keep it as simple as possible since I think that gh is about simplicity and convenience.

  7. ShubhankarKG commented on Sep 21, 2020

    @ShubhankarKG
    Contributor

    Perhaps

    gh config get remote
    gh config set remote url

    ?

    Then, when the prompt configures a default, we can say

    Your remote is configured to url. To change it, use gh config set url.

    Or something along those lines.

  8. jcmurray commented on Sep 21, 2020

    @jcmurray
    Author

    I'm minded not to pre-empt a specific solution but to let the gh developers come to a suitable use case/syntax that fits in with their gh cli command design and with any other enhancement requests they need to take into account to solve the issue I initially raised and hope these comments help them understand the issues.

    Just a couple of observations for the record though:

    • The get matches my previous point 1, so I can query the value the base remote setting.
    • The use of the word remote doesn't capture the sense of the what the get is meant to do. What is being cached is an identification of the single upstream remote repo that you've forked on github, cloned locally and which contains all the issues and pull requests that you're interested in. Your repo can contain many remotes. If it was up to me I'd maybe use something like base_remote to clarify its use.
    • The set for a remote url doesn't seem to address the second point I made of being able to clear out the cache. I can't see how I'd be able to get the config setting back to the unset state using this syntax without overloading the meaning of url value.

    Just my 2-pence worth.

  9. ShubhankarKG commented on Sep 22, 2020

    @ShubhankarKG
    Contributor

    Totally agreed on the remote part, just that I couldn't come up with a better name at the time of writing.

    On the set part, if we have the reset functionality, we will have to prompt again the next time this pops up. The benefit with set would be that we can change the config to something, rather than leave it empty.

  10. jcmurray commented on Sep 22, 2020

    @jcmurray
    Author

    I don't have any problem with the prompt. It keeps things simple; I do it once ( as long I get the selection right :-) ) and I don't have to worry about getting a URI wrong by mis-typing or cut/paste since it has to be one of the remotes from git remote -v. If you want to discuss the 'tty prompt' in more general terms feel free to open an issue about it specifically.

  11. added
    coreThis issue is not accepting PRs from outside contributors
    on Oct 22, 2020
  12. jbelina commented on Sep 27, 2022

    @jbelina

    I found my way here because of the article below. I picked the wrong repo when using gh repo sync; Then I couldn't figure out how to undo or switch the setting. I looked around the CLI documentation for gh repo and couldn't find anything.

    source: https://dev.to/utsavladani/how-to-change-base-repo-in-github-cli-5fhp

  13. mislav commented on Dec 22, 2022

    @mislav
    Contributor

    Thanks everyone for your feedback and sorry for the nuisance that was having to edit .git/config manually. In the most recent release, there is now the gh repo set-default --unset command for this. The documentation is at gh repo set-default --help. Please leave further feedback here #6777

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

    coreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLI

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions