7

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!

2
  • See this question: stackoverflow.com/questions/41044992/… Commented May 11, 2018 at 1:42
  • 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. Commented May 11, 2018 at 19:58

3 Answers 3

12

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://
Sign up to request clarification or add additional context in comments.

Comments

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)

Comments

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.