Tuesday, August 26, 2008

Use http proxy for git client

I am using a network behind a http proxy. As more and more Rails projects migrate to Git, for accessing those external Git repositories, I'd like to have a method to configure Git client to go through the http proxy. By searching the web, I found several solutions. After some trying, I found the easiest approach is to use transconnect.

I am using Ubuntu and find that there is no package support for transconnect. So I have to install it manually from the source code, fortunately, it is fairly easy to setup transconnect. Following is the steps:

1) Download transconnect source code from its website

2) Uncompress the .tar.gz package, to install it, simply type:
make install

The above is the standard installation, for others, please refer to INSTALL located within the uncompressed directory.

3) A new directory '.tconn' will be created under your HOME directory by the installer and a config file 'tconn.conf' will be copied to that directory. Open 'tconn.conf', you will find two options named 'proxyserv' and 'proxyport'. Replace the default value with the proxy you are in use.

And that's all for setting!

4) It is easy to start transconnect by exporting an environment variable:

After that, try your git client, it should work on current terminal by going through the proxy you have set.

5) It is also easy to stop transconnect. In the terminal you have exported LD_RELOAD, simply unset it.


Yes, that's all, enjoy!