Git子模块 - 权限被拒绝

Max*_*Max 17 git github git-submodules

我无法克隆我的私有git存储库中存在的子模块.我有权访问整个存储库,

使用了以下命令但是工作,请帮忙.克隆现有存储库中子模块的正确方法是什么?

djrecker$ git submodule update --init --recursive
Submodule 'Path' (git@github.com:Path) registered for path 'App'
Cloning into 'Path'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)

小智 33

我面临同样的问题.问题出在你的github repo上,你可能正在使用一些旧的ssh密钥.

您需要更新当前的ssh密钥.

Steps involved are:

1. vim ~/.ssh/id_rsa.pub
2. copy the ssh key
3. Go to the github settings
4. Select the option ssh keys
5. Remove the old ssh keys not used anymore.
6. Add a new ssh key.
7. Try running the "git submodule update --recursive"
Run Code Online (Sandbox Code Playgroud)

这对我有用!!


Sil*_*eel 10

我有这个问题.在我的情况下,没有在服务器上正确设置公钥(〜/ .ssh/id_rsa).

确保您获得所有子模块:

参考:Git update子模块递归

# This must be called twice. Once for new and once for existing submodules.
git submodule update --init --recursive
git submodule update --recursive
Run Code Online (Sandbox Code Playgroud)

要使用密钥诊断权限问题:

检查子模块的详细信息

  • .gitmodules在项目根文件夹中打开,确保看起来没问题.根据@VonC的建议,尝试将它们克隆到单独的文件夹中.
  • 您可能希望将子模块从使用SSH切换到HTTPS.这将允许您键入用户名和密码.但这可能会导致您的队友出现问题并构建自动化.先与他们交谈.


Čam*_*amo 10

在我的情况下,问题是由控制台引起的,它没有要求我输入密码。解决方案是将控制台从 CMDER 更改为 Gitbash。当我使用 CMDER 时,它不会显示导致此访问被拒绝问题的密码窗口。


Cem*_*m.S 6

  • 在Windows上:

就我而言,当我使用常规命令行(Git CMD)时,它抱怨的是同一问题。然后我尝试了Git Bash,再也没有问题了。


ang*_*kar 5

有趣的是,在类似的情况下,使用 HTTPS 链接对我有用。