Skip to content

support defaulting to SSH remotes #546

Description

@vilmibm

Describe the feature or problem you’d like to solve

Some users prefer that remotes be interacted with over SSH exclusively but we currently default to https in a few places.

Proposed solution

Supporting a preferSSH setting in gh's config. This requires actually thinking through some UX; we can either expect people to hand-edit the config, offer a hyper specific command just for this setting, or add a gh config key value style command.

How will it benefit CLI and its users?

People like me who prefer SSH over HTTPS will be happy.

Additional context

i'm fine with this being hand-edit for now but i feel like we're only going to find more cases where we want a gh config style command.

Activity

  1. jasonkarns commented on Feb 25, 2020

    @jasonkarns

    FWIW, I use the following git configuration to remap all http(s) URLs to SSH:

    [url "[email protected]:"]
    	insteadOf = http://github.com/
    	insteadOf = https://github.com/

    I would also personally enable any preferSSH option if it were available. But assuming my git configuration above still works when cloning via gh, it wouldn't seem necessary? (I don't know how gh interacts with git under the hood as to whether this config option would be respected implicitly or not.)

  2. timja commented on Mar 4, 2020

    @timja

    Jasons workaround worked for clone and fork for me

  3. vilmibm commented on Mar 4, 2020

    @vilmibm
    ContributorAuthor

    TIL insteadOf, thanks @jasonkarns . I think we'd respect that in all cases...

  4. lindskogen commented on Mar 17, 2020

    @lindskogen

    I tried using insteadOf but then I couldn't use cargo, the rust build tool, anymore since it's index is on GitHub and cargo uses https references.

  5. jasonkarns commented on Mar 18, 2020

    @jasonkarns

    @lindskogen apparently this is a known issue with libgit2 (and therefore cargo). cargo has a workaround: rust-lang/cargo#2078 (workaround is top of issue description)

    libgit2 pr: libgit2/libgit2#4667

    However, there's another workaround, which I use to avoid a similar problem with homebrew clones.

    # in ~/.config/git/config
    # important that this goes before the [url "[email protected]:"] line causing these problems
    [includeIf "gitdir:Homebrew/"]
    	path = config.homebrew
    
    # in ~/.config/git/config.homebrew
    [url "https://github.com/"]
    	insteadOf = [email protected]:
    	insteadOf = https://github.com/

    If you're not familiar with conditional includes, the way this works is that, for git repos whose repo path matches Homebrew, it includes an additional gitconfig file. The additional gitconfig file in this case does the opposite url.insteadOf transformation. (It translates ssh urls to https instead of vice versa.) A similar approach would work, assuming you can identify a portion of your cargo-index clone's path to use for the conditional include.

  6. self-assigned this
    on Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementa request to improve CLI

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions