Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Submodule Update - Permission denied

Tags:

git

gitlab

I have a git repository A that contains a submodule B. When I execute git submodule update --init --recursive in repository A to update the submodule, I get a Permission denied (publickey) error. The ssh key is correctly added to the remote (gitlab) and I can clone both repositories independently via ssh. Cloning B outside of A works. Repository B is in the same group as repository A (on gitlab).

I tried the following:

  • Setting an absolute reference in the .gitmodules
  • Changing the reference in .gitmodules to http
  • Making a clean clone of A
  • Adding a fresh ssh key (with and without passphrase)
  • Cloning repository A with option --recursive

How can I solve the problem?

The .gitmodules contains the following content:

[submodule "B"]
    path = path_to_B
    url= ../B.git

The complete error message:

Cloning into '{path_to_B}'...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of '{git@.../B.git}' into submodule path '{path_to_B}' failed
Failed to clone '{path_to_B}'. Retry scheduled
Cloning into '{path_to_B}'...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of '{git@.../B.git}' into submodule path '{path_to_B}' failed
Failed to clone '{path_to_B}' a second time, aborting
like image 852
hpatjens Avatar asked Feb 09 '26 23:02

hpatjens


1 Answers

Cloning repository B manually into the location of the submodule solved the issue. After that, updating worked again.

like image 105
hpatjens Avatar answered Feb 12 '26 16:02

hpatjens