当前位置: > > > 解决git submodule update下载子模块时报 Permission denied 错误

解决git submodule update下载子模块时报 Permission denied 错误

1,问题描述

前段时间编译 Potatso,首先通过 git 命令将其从 GitHub 上下载到本地。主工程下载完毕后,还需要下载其内部的子模块。这个同样使用 git 命令即可:
git submodule update --init
命令执行后子模块并没有成功更新下拉,报如下错误:
Cloning into ‘xxxxxxx’… 
The authenticity of host ‘github.com (XXX.XXX.XXX.XXX)’ can’t be established. 
RSA key fingerprint is …… 
Are you sure you want to continue connecting (yes/no)? yes 
Warning: Permanently added ‘github.com,XXX.XXX.XXX.XXX’ (RSA) to the list of known hosts. 
Permission denied (publickey). 
fatal: Could not read from remote repository.

2,解决办法 

(1)在项目的文件夹下有一个 .gitmodules 文件,打开发现这里面的模块的 URL  git@github.com:XXXXXX/XXXXXX.git 这种形式。

(2)我们把 git 形式的 url 改为 https 形式。

(3)保存后执行如下命令,重新同步一下子模块信息。
git submodule sync

(4)再次执行如下代码,即可成功下载子模块了。
git submodule update --init
评论1
  • 1楼
    2017-09-29 18:46
    yanqueen2011

    也可能是http://

    站长回复

    多谢提醒。