2009-11-12 118 views
107

我正在使用http代理。我試圖用他們的「回購」工具克隆Android的源代碼樹。如何將`git:`url轉換爲`http:`url

該工具堅持使用git://網址,即使http://網址也適用。因此,我無法下載源代碼。

是否有可能迫使git總是使用http

編輯:我的http_proxy配置正確。例如,這個工程:

git clone http://android.git.kernel.org/platform/manifest.git 

但這並不(錯誤=連接超時):

git clone git://android.git.kernel.org/platform/manifest.git 

所以this answer並沒有真正幫助我。

+0

看到這個[前面的回答(http://stackoverflow.com/questions/128035/how-do-i-pull-from-a-git-repository-through-an-http-proxy/397642#397642) 。 – 2009-11-12 15:03:45

回答

243

這裏是重寫默認協議GitHub上的例子:

git config --global url.https://github.com/.insteadOf git://github.com/ 
+16

有助於防火牆阻止git協議! :) – Turowicz 2013-06-14 15:36:58

+8

不是爲我工作:( – 2015-03-30 11:18:17

+0

這個工作,是非常簡單的。這應該是公認的答案 – 2015-07-17 13:12:36

35

我不知道這repo工具如何使用Git的(如果你可以配置「回購」使用http協議),但你可以嘗試使用url.<base>.insteadOf配置變量欺騙(見git-configgit-fetch聯機幫助頁)。

您是否嘗試過使用core.gitProxy穿過防火牆,如果是使用Git協議的problme?

+2

謝謝,這個「insteadOf」變量正是我所需要的。 – noamtm 2009-11-17 15:14:57

22

我有同樣的問題,在一個Git倉庫遞歸獲得子模塊。我背後是一個瘋狂的防火牆,它不允許在git端口上傳出連接。子模塊的一些子模塊編碼爲git://github.com/blah/blah.git。這導致我的子模塊的遞歸人口死亡。解決方法如下:

git config --global url."https://<GITUSERNAME>@".insteadOf git:// 

這將替換git://在所有子模塊庫URL https://<GITUSERNAME>@。您需要用您自己的git用戶名替換<GITUSERNAME>。另請注意,--global是必需的;只是將此配置添加到基本存儲庫目錄不起作用。

+0

感謝您實際包括解決方案... – GalacticJello 2015-03-06 14:38:04

+3

Y不只是使用 git config --global url。「https://」.insteadOf git:// 如此處所示? https://github.com/angular/angular-phonecat/issues/141 我的意思是用戶名強制性的? – 2015-06-19 07:11:59

1

可以在~/.gitconfig驗證,如果你覆蓋SSH以https://,反之亦然。