我有一个名为A的git代码库,其中包含一个子模块B。当我在A代码库中执行
我尝试了以下解决方法:
完整的错误信息:
git submodule update --init --recursive
命令以更新子模块时,会出现Permission denied (publickey)
错误。虽然ssh密钥已成功添加到远程Gitlab上,并且我可以独立使用ssh克隆两个代码库,但是在A代码库外克隆B代码库则可行。
代码库B与代码库A在同一Gitlab组内。我尝试了以下解决方法:
- 在
.gitmodules
中设置绝对路径 - 将
.gitmodules
中的引用更改为http - 对A进行干净的克隆
- 添加新的ssh密钥(有和无密码)
- 使用
--recursive
选项克隆A代码库
.gitmodules
文件的内容如下:[submodule "B"]
path = path_to_B
url= ../B.git
完整的错误信息:
Cloning into '{path_to_B}'...
git@gitlab.com: 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}'...
git@gitlab.com: 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