I work on site for a client 2 days a week, building apps for them. Recently, my team moved in to a different building that has different policies for connectivity and allowed access on the web.
Unfortunately, this new policy destroyed my ability to install anything using the “git://” protocol – which includes a lot of NPM modules and other repositories on Github. Apparently, port 9418 (which is the “git://” protocol port number) is entirely blocked by the webfilter here:
<sarcasm>Yeah, thanks corporate webfilter. That helps, SSSOOOooo much!</sarcasm>
There are two fixes for this, one of which requires every developer everywhere to not use “git://”. Fortunately, Git provides a fix internally and NPM is smart enough to defer to Git directly, when specifying a repository to install instead of an NPM module.
Rewriting git:// to https://
To fix the problem (by working around it entirely), you need to configure Git to rewrite the URL for git:// based protocols.
Open your ~/.gitconfig file and add a [url] entry, like this:
This entry tells Git to replace “git://github.com” with “https://github.com” for every action it takes.
Now, when I attempt to install a library using the “git://” protocol, it works just fine!
On the surface, it looks like everything is working like normal. Behind the schenes, though, Git is replacing “git://” with “https://” for this to work.
Command-Line Fix & More Info
If you want to add this via command-line, without the need to edit the config file by hand, you can do it like this:
But I prefer to edit the config file by hand. It’s easier for me to make sure I got it right.
Also – the best information I found about this was via command line “git-proxy –help”. This gives a rather verbose and sometimes tedious overview of everything git can do for URLs, including the Git Proxy configuration. There were some websites that had a little info, but nothing that gave me what I needed to know directly.