Create a tunnel to github with the git default daemon port like this:
$ ssh -L9418:github.com:9418 myuser@myhomessh.com
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.
Thanks for these instructions, I did all of the above and I am able to clone, but when I tried to push, I am getting these errors:
github.com[0: 127.0.0.1]: errno=Operation timed out
fatal: unable to connect a socket (Operation timed out)
Do you know what the reason might be? I really want to get git working behind my stupid corporate firewall