I am trying to update the submodules of this git repositary but I keep getting a fatal errors:
[root@iptlock ProdigyView]# git submodule update --recursive
Cloni
This is happened that many times for me that I put a function in my .bash_profile (works on BSD sed / GNU / Mac):
gitfix () {
if [ -f "./.gitmodules" ] ; then
sed -E -i.bak -e "s/(url *= *)(.*:)(.*)/\1https:\/\/github.com\/\3/g" .gitmodules \
git submodule sync
git submodule update --init --recursive
fi
}
A one liner:
sed -E -i.bak -e "s/(url *= *)(.*:)(.*)/\1https:\/\/github.com\/\3/g" .gitmodules ; git submodule sync ; git submodule update --init --recursive
vim search/replace:
%s/\(url\s*=\s*\)\(.*:\)\(.*\)/\1https:\/\/github.com\/\3/
Underlying solution based on Daniël 's answer
The following steps will fix the problem.
git submodule sync
git submodule update --init
Hope this helps.
If it can help some people:
I update my .gitmodules
[submodule "example"]
path = example
url = https://github.com/webhat/example.git
Then I update my .git/config too
[submodule "example"]
url = https://github.com/webhat/example.git
Like some of you said it before (and I thank you).
Then I update my .git/modules/example/config
[remote "origin"]
fetch = [...]
url = https://github.com/webhat/example.git
And to finish I do
git submodule sync
git submodule init
git submodule update
You can manually pass in the key in Build --> "Execute shell" section of jenkins job :
ssh-agent bash -c 'ssh-add {path_to_private_key}; git submodule update --init --recursive'
Example:
ssh-agent bash -c 'ssh-add /var/lib/jenkins/.ssh/jenkins_rsa; git submodule update --init --recursive'
I had this same issue. However, in my situation, the team wanted to use the SSH access from the .gitmodules, so modifying the URL to use http:// was not an option.
Ultimately, my issue was having an incorrect ~/.ssh/config file. The config file had some erroneous settings, so I was actually trying to access the incorrect server every time I'd really want to access git@github.com. I found this out by executing the following command:
ssh -vT git@github.com
The third line or so should say this:
debug1: Connection to github.com [<ip address>] port <port num>
If you aren't attempting to connect to github.com, then your config file is pointing you off course.
Turns out I didn't need any of the stuff in my config file anyway, so I was safe to delete it. If you want to maintain a config file, here is a good article on that:
http://nerderati.com/2011/03/17/simplify-your-life-with-an-ssh-config-file/
Also, these GitHub docs really helped me debug my issue:
https://help.github.com/articles/error-permission-denied-publickey
https://help.github.com/articles/what-ip-addresses-does-github-use-that-i-should-whitelist
Adding new answer instead of edit for greater visibility to anyone experience the same problem I was...
I had the exact opposite. Private Bitbucket repo & submodule for work. Always got this error...
fatal: repository 'http://bitbucket.org/companyname/submodule-repo-name.git' does not exist
fatal: clone of 'http://bitbucket.org/companyname/submodule-repo-name.git' into submodule path
'/Users/me/path/to/repo-using-submodule/folder' failed
Failed to clone 'submodule/folder'. Retry scheduled
fatal: repository 'http://bitbucket.org/companyname/submodule-repo-name.git' does not exist
fatal: clone of 'http://bitbucket.org/companyname/submodule-repo-name.git' into submodule path
'/Users/me/path/to/repo-using-submodule/folder' failed
Failed to clone 'submodule/folder' a second time, aborting
I had to manually go into my .git/config file and update this:
[submodule "submodule-name"]
url = https://bitbucket.org/companyname/submodule-repo.git
with this:
[submodule "submodule-name"]
url = git@bitbucket.org:companyname/submodule-repo.git
Not sure how to set this up so me and all my coworkers can use the submodule without tweaking, but got me past my several month long struggle with this.