Last Updated: November 19, 2020
· jbleuzen

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

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

Related protips:

Force a "git stash pop"

3 Responses
Add your response

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."".insteadOf git://
over 1 year ago ·

You can also use "url.instedOf" to create shortcuts:

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

I can then do;

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

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 ·