2011-11-19 71 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/ 

標的解決方案基於丹尼爾的回答