sitezg
Last Updated: June 28, 2016
·
50.65K
· jbleuzen

Force git to clone with "https://" instead of "git://" urls

git

If you can't clone a repository with a "git://" url because of a proxy or firewall, here is a little git configuration that will force git to use "https://" even when you'll type "git://" URL.

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

With this command, it will add the following lines in you .gitconfig :

[url "https://"]   
    insteadOf = git://

That way, you don't have to care about using "git://" or "https://" when you are cloning repo, both urls will work.
Maybe a well known tweak but discovered it lately...

3 Responses
Add your response

8860

You can also limit this URL rewriting to an explicit list of Git repos that are outside your firewall. This way you can still use the git:// scheme inside your LAN with your internal repos.

git config --global url."https://github.com".insteadOf git://github.com
over 1 year ago ·
14076

@steve-jansen:
You can also use "url.instedOf" to create shortcuts:

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

I can then do;

git clone github:dolmen/github-keygen.git
over 1 year ago ·
14618

Thanks for this tip, for some reason I can't get https connections to work behind my company's proxy, so i used the opposite of this to force git:// connections. Thanks!

over 1 year ago ·
Filed Under