Monday, 16 January 2017

Git behind a Corporate Proxy

We have been recently told that we are to use VSTS to store our code sooner than Bitbucket.
However despite the site being our corporate site the corporate firewall blocked access.
It took a while but I found the issue & a solution, which I thought might to file away for an other day.

The problem is as follows:
1.       The git installation has its ssh certs in the ‘wrong’ place;
2.       A proxy is needed to access SCM on VSTS;
3.       Adding the Company proxy disables all other GIT access that does not require your Company credentials.

The solution is ultimately simple:
1.       Copy the Certs to the path GIT is expecting them;
2.       Only set the proxy for the project that needs it.
This can be done by setting the proxy on the clone command:
Ie.
               git clone https://myproject.visualstudio.com/_git/Java-two --config "http.proxy=http://mycompany.proxy.server:8080"

Now you can access everything as before.

Two helpful commands I found along the way are:

$git config --global --list

Which lists the configuration for all the repositories.

git config --global --unset http.proxy

Which allows you to remove a setting from all of your Git configuration.

Finally if you jump into the project folder and want to see the settings for the project then simply use the –local switch.
Ie.
$git config --local --list

And that's it!