Using ssh vs https with github submodules
Asked Answered
S

3

6

I would like to set up a public GitHub repo with submodules. GitHub offers two ways of connecting - https:... & git@... protocols. For the team working on the project, git@... is much easier to use because we all use proper ssh certificates. But for the casual user who is not a member of the team, https:... is the only option. The git submodules require a full URL.

How can we set up repository submodules so that both the developers and casual contributors can use the system equally well? Thanks!

Seay answered 10/5, 2018 at 23:22 Comment(2)
See this question: #41045492Kohler
Consider whether submodules are the way to go, as opposed to making packages and using a package manager. Many package managers will draw from a Git repository.Ulent
F
10

Publish your submodules with https:// protocol but make all your developers to use ssh:// protocol. Git can substitute one protocol with the other on the fly:

git config url."ssh://git@".insteadOf https://
Frigid answered 11/5, 2018 at 19:59 Comment(0)
V
2

Building on top of phd's answer, I found that I had to specify --global in order to make sure the config applies to the submodules as well. This is the command I ran:

git config --global 'url.ssh://[email protected]' 'https://example.com:PORT'

(Posted as an answer since I don't have the reputation to comment)

Venation answered 22/7, 2021 at 15:59 Comment(0)
Q
1

First, it is not the "git protocol", but actually the SSH one, with URL like [email protected]:user:repo.
(there actually is a git protocol, no longer used these days)

Second, keep the URLs as https for the submodules: it is easy to cache the credentials (username/password) with a credential manager (like GCM for Windows).
But that means those users need to be added as contributors (whether or not you are using HTTPS, or SSH URLs)

Quadriceps answered 11/5, 2018 at 4:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.