Jan 29 2014

HTTP Proxy Per Git Repository

Published by at 1:38 pm under Programming

I’ve finally made the switch to using Git instead of Subversion as the source control system at work.  I’ve been using it for a while with a couple of personal projects that I’ve got hosted on BitBucket using the wonderful SourceTree, created by my friend Steve Streeting, and I’ve come to prefer it to Subversion. At work, I set up a Stash server and have been syncing our Subversion repository into it for a while but never quite made the jump to Git until now.

The first hurdle I’ve hit is with proxy settings.  On my development machine I’ve got cloned BitBucket repositories and to be able to use those I need to connect through a proxy.  Thankfully SourceTree makes it easy to configure Proxy settings for Git.  However, these are system wide settings.  Now that I want to work with our internal Stash server I need Git to use the proxy for some repositories but not for the internal one.

Given that I’ve got lots of external repositories but only one internal repository I’ve left the Git default settings to use the Proxy server.  Unfortunately SourceTree doesn’t help with specifying a proxy for a single repository but it’s not hard.

  • Open the local repository in Explorer and head into the .git directory (you may need to show hidden files & folders)
  • Open up the config file in your favourite text editor
  • At the bottom of the [core] section of settings add the following:
    [http]
        proxy =
  • Save the config file.

That’s all there is to it.  You don’t even need to restart SourceTree for it to pick up the change.  This change is basically telling Git not to use a Proxy for this repository.  Alternatively, on the “proxy =” line you could specify a proxy to use, e.g. if you have lots of internal repositories and only one external then it would be easier to default the global settings to no proxy and only specify a proxy for just one repository.

Hope this helps!

No responses yet