如何将`git:` url 转换为`http:` url [英] How to convert `git:` urls to `http:` urls

查看:34
本文介绍了如何将`git:` url 转换为`http:` url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

这个工具坚持使用 git:// URLs,即使 http:// URLs 也有效.结果下载不了源码.

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

是否可以强制 git 始终使用 http?

Is it possible to force git to always use http?

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

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

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

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

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.

推荐答案

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

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

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

url.

的 Git 文档.base>.insteadOf:

git config [--global] url.<base>.insteadOf <other_url>

任何以该值开头的 URL 都将被重写为以 开头.当多个替代字符串匹配给定 URL 时,将使用最长匹配.

Any URL that starts with this value will be rewritten to start, instead, with <base>. When more than one insteadOf strings match a given URL, the longest match is used.

这篇关于如何将`git:` url 转换为`http:` url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆