Create a tunnel to github with the git default daemon port like this:
$ ssh -L9418:github.com:9418 [email protected]
And clone repositories replacing github.com
with localhost
, like so:
$ git clone git://localhost/someuser/someproject.git
If you want to preserve the “correct” metadata, there are several options
- replace localhost origin with github.com after cloning
git remote rm origin git remote add origin git://github.com/someuser/someproject.git
- add github.com to your hosts file and point it to 127.0.0.1
- add github.com to your ~/.ssh/config:
Host github.com HostName localhost
- use your favourite packet forwarder, example for Mac OS X:
sudo ipfw add 00100 fwd 127.0.0.1,9418 tcp from me to github.com dst-port 9418
and when you are done, don’t forget to remove it:
sudo ipfw delete 00100
(use caution, especially if you are using ipfw already and have rule 00100 in place)
Stuck behind a corporate firewall? Justin Bailey has a good guide. Scroll down for a *nix solution as well.
Here's my writeup for getting read-write access via ssh through a firewall:
http://technuggets.tumblr.com/post/2584970503/accessing-github-with-ssh-through-a-firewall