【发布时间】:2022-10-13 13:51:59
【问题描述】:
我在 bitbucket 中托管了两个存储库 - 我有一个访问密钥设置,可用于单独克隆每个项目。存储库 A 具有存储库 B 作为子模块。
在 Windows 上...成功克隆 repo A 后,git submodule update --init 失败,原因如下:
Cloning into 'C:/Path/to/submodules/B'...
git@bitbucket.org: 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@bitbucket.org:org/B.git' into submodule path 'C:/path/to/submodules/B' failed
Failed to clone 'submodules/B'. Retry scheduled
.gitmodules 设置如下
[submodule "submodules/B"]
path = submodules/B
url = git@bitbucket.org:org/B.git
...
如果我采用.gitmodules 中指定的 URL 并克隆该存储库,则它可以正常工作git clone git@bitbucket.org:org/B.git
似乎试图通过git submodule update --init 克隆的存储库无法看到/使用我添加的 ssh 访问密钥。
Git Submodule - Permission Denied 建议无效
- 也许密钥需要刷新?不,该密钥非常适合下载所有其他存储库
-
可能是密钥本身有问题,试试
ssh -vT git@github.com将其更改为bitbucket.org后,它工作得非常好,身份验证成功。 - 我对 http 没有这个问题:/- 我也没有,我讨厌 ssh,但是,唉,这是必需的。
如何解决这个问题?或者我缺少什么配置?
我将在开发 docker 容器环境中执行此操作,因此不需要排除它。
这不像以下问题:
【问题讨论】:
-
考虑使用 GIT_TRACE 和/或您拥有的任何系统跟踪工具,以查看子模块克隆是否出于某种原因使用与手动
git clone不同的 ssh 实现。我认为这是最有可能的罪魁祸首:您的计算机上有两个不同的ssh命令,其中一个在这里有效,而另一个无效。
标签: git ssh bitbucket git-submodules