Fatal Error when updating submodule using GIT

Solution 1:

The issue is that git can't find the public key needed to download the repo from your server, the solution is to use the public url.

In the file .gitmodule you will find the following entry:

[submodule "example"]
    path = example
    url = [email protected]:webhat/example.git

The URL need to be changed to the public URL for the module:

[submodule "example"]
    path = example
    url = https://github.com/webhat/example.git

As you can see the prefix git@ has been changed to https:// and the infix : becomes /

EDIT: In your own repository you might need to use git:// rather than https://

The previous answer was unclear to me, so I added this.

EDIT 2: If you find you need to run git submodule sync or need to edit .git/config to get this to work, you have likely set up remotes for the submodules.

Solution 2:

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

Solution 3:

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'

Solution 4:

The following steps will fix the problem.

  1. Delete the folder of the submodule on your local.
  2. Do git submodule sync
  3. then git submodule update --init

Hope this helps.