Difference between revisions of "Using git with a proxy"
(→Resources) |
(→Resources) |
||
Line 55: | Line 55: | ||
* http://blogs.gnome.org/juanje/2009/07/17/git_behind_proxy/ | * http://blogs.gnome.org/juanje/2009/07/17/git_behind_proxy/ | ||
* https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy - shows scripts for both 'socat' and 'nc' | * https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy - shows scripts for both 'socat' and 'nc' | ||
+ | * http://sitaramc.github.com/tips/git-over-proxy.html - shows socat proxy and ssh tunnel (but is not very clear?) |
Latest revision as of 18:18, 10 December 2012
[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.
Contents
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.
git urls
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.
- http
- socks
- 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
Resources
- How to use corkscrew to access git using a http://kunilkuda021.wordpress.com/2010/02/11/accessing-git-under-authenticated-proxy/
- http://bardofschool.blogspot.com/2008/11/use-git-behind-proxy.html
- http://stackoverflow.com/questions/5529218/how-to-use-git-behind-a-proxy
- http://blogs.gnome.org/juanje/2009/07/17/git_behind_proxy/
- https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy - shows scripts for both 'socat' and 'nc'
- http://sitaramc.github.com/tips/git-over-proxy.html - shows socat proxy and ssh tunnel (but is not very clear?)