Using git with a proxy
[as of 2012.12.10 this article is a work in progress]
I found it very difficult to set up git to use a proxy at my work environment. Here is some information that I found, that hopefully will be helpful to other people looking into this problem.
Different kinds of proxies and protocols
Before you can have git operate through a firewall via a proxy, you first have to understand what type of proxy you have, and what type of protocol you will be using to access your target git repository.
Git can operate over either http (port 80), https (port 437), use the git protocol directly (port 9418) or use the git protocol over ssh (port 22).
If you are in an environment where direct access to the internet is prohibited by a firewall, then you may be able to access the target repository you are interested in via a proxy. For example, in many corporate environments, direct access to http is not allowed, but an http firewall is provided to allow access to the world wide web. If your target repository is accessible via the http protocol on port 80, it is likely that you can access it directly from git, with no extra steps.
The prefix to the URL for a repository indicates the type of protocol (and implies the port) for accessing that respository. Note that many git publishing sites provide access via multiple protocols, so if one is unavailable it may be possible to use an alternate method to access the site.
Here are some common protocols, and some example URLs associated with them:
- http: git clone http://domain.com/dir/repository.git
- https: git clone https://domain.com/dir/repository.git
- git: git clone git://domain.com/dir/repository.git
- git over ssh: git clone git+ssh://domain.com/dir/repository.git
different kinds of proxies
There are different kinds of proxies which may be available to you.
- SOCKS4 vs. SOCKS5
git proxy configuration
You can configure git to use a proxy helper script to use to work with a proxy. This script is specified in the git configuration file in the [core] section, with the attribute name "gitproxy".
The helper script, by convention, is called git-proxy.sh, but you can name it anything you want, and configure git to use that:
$ git config --global core.gitproxy /path/to/bin/git-proxy.sh
Note that it is possible to use more than one proxy script, depending on the domain name of the repository. In this case, you provide multiple configuration values for the core.gitproxy configuration variable. This is explained here:
git proxy command
- How to use corkscrew to access git using a http://kunilkuda021.wordpress.com/2010/02/11/accessing-git-under-authenticated-proxy/