How to Convert `Git: ` Urls to `Http: ` Urls

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 

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

git clone git://

So this answer does not really help me.

1

5 Answers

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

git config --global url. git://

The exact values depend on the protocol in use. For example, the above command for git over ssh will look like:

git config --global url. :

Git documentation for url.<base>.insteadOf:

git config [--global] url.<base>.insteadOf <other_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.

8

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.<base>.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?

1

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://. This killed my recursive population of submodules. The workaround is the following:

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

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

1

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

Find your git account's git config file(.gitconfig), modify the followings:

    [user]
    email = your e-mail account


    name = your git account
    [url ":"]


    insteadOf = 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest