2011-11-19 70 views
26

我想更新这个混帐repositary的子模块,但我不断收到一个致命错误子模块时:致命错误更新使用GIT

[[email protected] ProdigyView]# git submodule update --recursive 
Cloning into core... 
Permission denied (publickey). 
fatal: The remote end hung up unexpectedly 
Clone of '[email protected]:ProdigyView/ProdigyView-Core.git' into submodule path 'core' failed 

还是这样

[[email protected] root]# git clone --recursive https://github.com/ProdigyView/ProdigyView.git 
Cloning into ProdigyView... 
remote: Counting objects: 438, done. 
remote: Compressing objects: 100% (275/275), done. 
remote: Total 438 (delta 172), reused 394 (delta 128) 
Receiving objects: 100% (438/438), 8.03 MiB | 5.19 MiB/s, done. 
Resolving deltas: 100% (172/172), done. 
Submodule 'core' ([email protected]:ProdigyView/ProdigyView-Core.git) registered for path 'core' 
Cloning into core... 
Permission denied (publickey). 
fatal: The remote end hung up unexpectedly 
Clone of '[email protected]:ProdigyView/ProdigyView-Core.git' into submodule path 'core' failed 

为什么任何想法这与子模块发生了什么?回购协议是这一个:

https://github.com/ProdigyView/ProdigyView

(子模块可以,如果我不尝试克隆它作为一个子模块被克隆。)

+1

如果它可以帮助,将在GitHub上的公钥做的工作对我来说。 –

回答

-4

想通了。 .gitmodule文件中的路径无法下载子模块。

+7

我有这个相同的问题。你能详细说明什么是错的,你是如何解决它的? –

+0

这就是我已经解决了这个问题的方法:在.gitmodules文件和.git/config文件中,您将看到要更新的子模块的url路径。如果它像git @ github ...那么将其更改为有效的网址:git // github.com/....它将解决问题。 –

+2

这个答案是非常不清楚的。 Khune Vu的建议也没有解决这个问题。 – awolf

59

问题是,git无法找到从您的服务器下载repo所需的公钥,解决方案是使用public url。

在文件.gitmodule你会发现下面的条目:

[submodule "example"] 
    path = example 
    url = [email protected]:webhat/example.git 

的URL需要改变公众对URL的模块:

[submodule "example"] 
    path = example 
    url = https://github.com/webhat/example.git 

正如你所看到的前缀git @已更改为https://和中缀变为/

编辑: 在自己的仓库,你可能需要使用git://而非https://

以前的答案是我不清楚,所以我加了这一点。

编辑2: 如果你发现你需要运行git submodule sync或需要编辑.git/config来得到这个工作,你可能已经设置了遥控器的子模块。

+2

今天我遇到了同样的问题,Github似乎只是通过HTTPS nowadasy提供公共克隆。在您的示例中的URL会一直'的https:// github.com/webhat/example.git'然后 – bfncs

+0

@boundaryfunctions更新 –

+1

感谢您的快速反应,投起来。 – bfncs

29

如果它可以帮助一些人:

更新我.gitmodules

[submodule "example"] 
    path = example 
    url = https://github.com/webhat/example.git 

然后更新我的.git/config中太

[submodule "example"] 
    url = https://github.com/webhat/example.git 

像有些人说,之前(和我感谢你)。

然后我更新我的。混帐/模块/例子/配置

[remote "origin"] 
    fetch = [...] 
    url = https://github.com/webhat/example.git 

而完成我做

git submodule sync 
git submodule init 
git submodule update 
+0

的'git的子模块的更新,这是一个完整的解决方案:) – almaruf

1

我有同样的问题。但是,在我的情况下,团队希望使用.gitmodules中的SSH访问,因此修改URL以使用http://不是一个选项。

最终,我的问题是有一个不正确的〜/ .ssh/config文件。配置文件有一些错误的设置,所以实际上每次我真的想要访问[email protected]时都试图访问错误的服务器。我发现了这一点,通过执行以下命令:

ssh -vT [email protected] 

第三行左右就应该这样说:

debug1: Connection to github.com [<ip address>] port <port num> 

如果你不试图连接到github.com,那么你的配置文件正在指引你离开。

原来我的配置文件中并不需要任何东西,所以我可以安全地删除它。如果你想保持一个配置文件,这里是一个很好的文章:

http://nerderati.com/2011/03/17/simplify-your-life-with-an-ssh-config-file/

而且,这些GitHub的文档真的帮我调试我的问题:

https://help.github.com/articles/error-permission-denied-publickey

https://help.github.com/articles/what-ip-addresses-does-github-use-that-i-should-whitelist

1

以下步骤将解决该问题。

  1. 删除本地子模块的文件夹。
  2. git submodule sync
  3. 然后git submodule update --init

希望这有助于。

3

您可以手动传递中构建的关键 - >詹金斯工作的 “执行shell” 部分:

ssh-agent bash -c 'ssh-add {path_to_private_key}; git submodule update --init --recursive'

例子:

ssh-agent bash -c 'ssh-add /var/lib/jenkins/.ssh/jenkins_rsa; git submodule update --init --recursive'

+0

这是真正有用的前 'git的子模块sync': –

0

这是发生了许多对我来说,我在我的功能。.bash_profile中(适用于BSD SED/GNU /苹果机):

gitfix() { 
if [ -f "./.gitmodules" ] ; then 
    sed -E -i.bak -e "s/(url *= *)(.*:)(.*)/\1https:\/\/github.com\/\3/g" .gitmodules \ 
    git submodule sync 
    git submodule update --init --recursive 
fi 
} 

一个一个班轮:

sed -E -i.bak -e "s/(url *= *)(.*:)(.*)/\1https:\/\/github.com\/\3/g" .gitmodules ; git submodule sync ; git submodule update --init --recursive 

VIM查找/替换:

%s/\(url\s*=\s*\)\(.*:\)\(.*\)/\1https:\/\/github.com\/\3/ 

标的解决方案基于丹尼尔的回答