2009-11-12 119 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://,反之亦然。