Repository navigation
support defaulting to SSH remotes #546
Description
Activity
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
preferSSHoption if it were available. But assuming my git configuration above still works when cloning viagh, it wouldn't seem necessary? (I don't know howghinteracts with git under the hood as to whether this config option would be respected implicitly or not.)Reacted by Anton GolubReacted by Jan Tojnar, Nicolò Ribaudo, Tim Jacomb, Mislav Marohnić, Klas Mellbourn, Johan Lindskogen, Dave Powers, Andrei L, balazs4, Oleksii Filonenko and 21 moreJasons workaround worked for clone and fork for me
Reacted by Nate SmithTIL
insteadOf, thanks @jasonkarns . I think we'd respect that in all cases...Reacted by Jason Karns, Elias Gabriel and tomjI tried using
insteadOfbut then I couldn't use cargo, the rust build tool, anymore since it's index is on GitHub and cargo uses https references.@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 oppositeurl.insteadOftransformation. (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.Reacted by Johan Lindskogen and Andrei L
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
preferSSHsetting ingh'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 agh config key valuestyle 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 configstyle command.