(This is something that's cropped up for me mainly when using GitHub, so I don't mind too much if any solution is GitHub-specific. But the problem isn't GitHub-specific per se, and any solution needn't necessarily be either.)
You can always clone a public GitHub repo using https:
git clone https://github.com/my-user-name/SDL-mirror
If you have an SSH key that GitHub knows about, you can also clone the repo using SSH:
git clone [email protected]:my-user-name/SDL-mirror.git
(I think similar options apply when using Bitbucket.)
You have these two options when adding a submodule, too.
When adding a submodule, you'll often add the SSH version, so you can commit directly from the submodule after testing your changes in situ.
But what about people trying to clone your repo? They might not have SSH access to GitHub. So they'll clone your repo using the HTTPS URL... and then come unstuck when Git tries to clone the submodules using the SSH URLs.
This can also be an issue if you use a Git repo for system provisioning.
Ideally, I'd like Git to pull from the SSH URL if possible, and the HTTPS URL if not. That should make things work out of the box for everybody. Is there some way I can get it to do that?
What you can do is:
locally instruct Git to use ssh instead:
git config --global url.ssh://[email protected]/.insteadOf https://github.com/
That way, for your local repo, you are always using ssh, but for anyone cloning your repo, there are only https references.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With