Why to Setup Your Git Submodules as https:// not ssh
I was pulling a public GitHub repo the other day which featured submodules. The frustrating problem is whenever I tried to init the submodules with the line git submodule update --init --recursive
I got the error Git Submodule fatal: Could not read from remote repository
The Issue
This comment on Stack Overflow was the key to understanding the issue using a GitHub public url rather than using a public key.
I was cloning a public GitHub repo and the submodules were also public GitHub repos but I don’t use SSH authentication for GitHub, I use credential.helper osxkeychain and the submodule urls were using the format git@github.com:mileszs/ack.vim.git
rather than https://github.com/mileszs/ack.vim.git
. The former format requires you access GitHub via SSH, the later allows any public connection.
Please Setup Submodules Using Public URLs
The take-away from all of this is, please use public URLs (https://) not SSH (git@github.com:) when setting up your submodules.
Please Use this
git submodule add https://github.com/salcode/example.git
Not This
git submodule add git@github.com:salcode/example.git
I have fun with, result in I found exactly what I
was having a look for. You have ended my 4 day lengthy hunt!
God Bless you man. Have a great day. Bye
Glad to hear this article helped. Thanks.