How to convert `git:` urls to `http:` urls

匿名 (未验证) 提交于 2019-12-03 02:33:02

问题:

I'm working behind an http proxy. I'm trying to clone Android's source tree using their "repo" tool.

This tool insists on using git:// URLs, even though http:// URLs also work. As a result, I can't download the source.

Is it possible to force git to always use http?

Edit: my http_proxy is configured correctly. For example, this works:

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

But this doesn't (errno=Connection timed out):

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

So this answer does not really help me.

回答1:

Here's an example of rewriting the default protocol for GitHub:

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


回答2:

I don't know how this repo tool uses Git (and if you can configure 'repo' to use http protocol), but you can try to trick it using url..insteadOf configuration variable (see git-config and git-fetch manpages).

Have you tried to use core.gitProxy to pass through firewall, if it is the problme with using git protocol?



回答3:

I had this same problem with recursively getting submodules in a git repository. I'm behind a crazy firewall that doesn't allow outgoing connections on the git port. Some of the submodules of the submodules were coded as git://github.com/blah/blah.git. This killed my recursive population of submodules. The workaround is the following:

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

This replaces git:// with https://@ in all submodule repository URLs. You need to replace with your own git username. Also note that the --global is required; just adding this configuration to the base repository directory doesn't work.



回答4:

You can verify in ~/.gitconfig if you're overwriting SSH with https://, or vice versa.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!