如何将`git:`urls转换为`http:`urls

noa*_*mtm 132 git proxy

我在http代理后面工作.我正在尝试使用他们的"repo"工具克隆Android的源代码树.

此工具坚持使用git://URL,即使http://URL也有效.结果,我无法下载源代码.

有可能强制git总是使用http吗?

编辑:我的http_proxy配置正确.例如,这有效:

git clone http://android.git.kernel.org/platform/manifest.git
Run Code Online (Sandbox Code Playgroud)

但这不会(错误=连接超时):

git clone git://android.git.kernel.org/platform/manifest.git
Run Code Online (Sandbox Code Playgroud)

所以这个答案并没有真正帮助我.

Tob*_*obu 292

以下是重写GitHub默认协议的示例:

git config --global url.https://github.com/.insteadOf git://github.com/
Run Code Online (Sandbox Code Playgroud)

  • 防火墙阻止git协议时有帮助!:) (19认同)
  • 这个答案差不多适合我,除了我的存储库使用了一个`git@github.com:...`格式的网址.这工作:`git config --global url."https://github.com/".insteadOf'git@github.com:'`对我来说. (14认同)
  • 提示:“git Remote -v”立即显示“insteadOf”和“pushInsteadOf”配置的效果 (3认同)

Jak*_*ski 35

我不知道这个repo工具如何使用Git(如果你可以配置'repo'来使用http协议),但是你可以尝试使用url.<base>.insteadOf配置变量来欺骗它(参见git-configgit-fetch manpages).

您是否尝试过使用core.gitProxy防火墙,如果是使用git协议的问题?

  • 谢谢,这个"replaceOf"变量正是我所需要的. (2认同)

crc*_*tle 23

我在git存储库中递归获取子模块时遇到了同样的问题.我是一个疯狂的防火墙,不允许git端口上的传出连接.子模块的一些子模块被编码为git://github.com/blah/blah.git.这杀死了我递归的子模块.解决方法如下:

git config --global url."https://<GITUSERNAME>@".insteadOf git://
Run Code Online (Sandbox Code Playgroud)

这将替换git://https://<GITUSERNAME>@在所有子模块库URL.您需要<GITUSERNAME>使用自己的git用户名替换.另请注意,这--global是必需的; 只是将此配置添加到基本存储库目录不起作用.

  • Y不只是使用git config --global url."https://".insteadOf git://如此处所示?https://github.com/angular/angular-phonecat/issues/141我的意思是用户名是强制性的吗? (3认同)