Git子模块更新 - 权限被拒

4
我有一个名为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

你能尝试在 A 之外克隆 B 吗? - Matt Clark
在 A 之外克隆 B 完全没有问题。 - hpatjens
1个回答

1
将B仓库手动克隆到子模块位置解决了问题。之后,更新工作正常运行。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接