In this post I’ll show something that I just discovered and solved a problem I had once we introduced a in-house git repository: how to have many git repositories using proxies but have one that connects directly without proxy.
Lately we moved our source code repository, from a “standard” TFS repo to the git-based TFS repository that has been introduced with TFS 2013. Besides working with github repositories, now I had to connect also to some a repository hosted inside the local network and authenticate using the local domain credentials.
All went well from within Visual Studio, but since you cannot do everything from VS, I also needed to connect to the internal repository via the git command line tools. The problem is that it didn’t connect.
After a bit of troubleshooting I realized that the problem was the proxy: I’m behind a corporate firewall, so I had to configure a proxy to connect to github. Unfortunately the proxy was not recognizing my connection as local, so was trying to resolve it on the internet, and of course it failed.
I had to remove the proxy configuration, and I could connect to my local git-based TFS repository, but I couldn’t connect to the other repositories unless I specified the proxy on each of the repositories that needed it, which was kind of tedious since I need proxy for all repos except one.
Looking through the git-config documentation I found the solution:
Set to the empty string to disable proxying for that remote.
This not only work when specifying a proxy for a specific remote, but also for the whole repository.
Without further ado, here are the command for this configuration.
First you specify your global proxy configuration
$ git config --global --add http.proxy "http://proxy.example.com"
Then you move to the repository for which you want to unset the proxy and add an "empty" proxy.
$ git config --local --add http.proxy ""
And in case you need to specify an empty proxy only for a specific remote
$ git config --local --add remote.<name>.proxy ""
It took me a day to understand the cause of the problem, hope this post will help other people in a similar situation.