Git has a config option called ‘core.gitproxy’ which allows you to use a command to tunnel the git:// protocol, which would normally go over TCP port 9418. So in my case, I’ve got a couple off-campus servers that I can use SSH tunnels with. I set up the typical SSH-based SOCKS proxy, thusly (you can also use apps like Shimo to manage tunnels for you):
$ ssh -D 1080 tycho@hostname
NOTE: If you are using ssh shared connection(controlmaster/controlpath), you will have to disable it(forwarding is not yet implemented in shared connection)
$ ssh -S "none" -D 1080 tycho@hostname
Then I use the tools which I’ve made available in this git repository to make cloning with the git:// protocol tunnel through SSH run transparently.
To use the tools, you need to first compile ‘connect.c’ and install the ‘connect’ binary to somewhere in your PATH (/usr/local/bin should work for this). Modify the ‘gitproxy’ script provided in the repository for your configuration (if you use the same command I used above, it should work fine without any editing). Once done editing it, install it as well.
Now tell git about the gitproxy script you just installed:
$ git config --global core.gitproxy gitproxy
Or if you want to use it for a single repository, run the command without ‘—global’ while you’re inside the working tree of the repository.
Or if you want to use it temporarily, use
$ export GIT_PROXY_COMMAND=gitproxy
Once this is all done, you should be able to simply do a git clone without any special URL mangling:
$ git clone git://github.com/tycho/crisscross.git
Initialized empty Git repository in /Volumes/Development/crisscross/.git/
remote: Counting objects: 1322, done.
remote: Compressing objects: 100% (723/723), done.
remote: Total 1322 (delta 915), reused 874 (delta 586)
Receiving objects: 100% (1322/1322), 566.77 KiB | 60 KiB/s, done.
Resolving deltas: 100% (915/915), done.
$