<?xml version="1.0" encoding="UTF-8"?>
<guide>
  <body>&lt;p&gt;Create a tunnel to github with the git default daemon port like this:&lt;/p&gt;
&lt;pre class=&quot;console&quot;&gt;&lt;code&gt;$ ssh -L9418:github.com:9418 myuser@myhomessh.com&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And clone repositories replacing &lt;code&gt;github.com&lt;/code&gt; with &lt;code&gt;localhost&lt;/code&gt;, like so:&lt;/p&gt;
&lt;pre class=&quot;console&quot;&gt;&lt;code&gt;$ git clone git://localhost/someuser/someproject.git&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want to preserve the &amp;#8220;correct&amp;#8221; metadata, there are several options&lt;br /&gt;
&lt;ol&gt;&lt;br /&gt;
&lt;li&gt;replace localhost origin with github.com after cloning&lt;br /&gt;
&lt;pre class=&quot;console&quot;&gt;&lt;code&gt;git remote rm origin
git remote add origin git://github.com/someuser/someproject.git&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;add github.com to your hosts file and point it to 127.0.0.1&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;add github.com to your ~/.ssh/config:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;Host github.com
  HostName localhost
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;use your favourite packet forwarder, example for Mac OS X:&lt;br /&gt;
&lt;pre class=&quot;console&quot;&gt;&lt;code&gt;sudo ipfw add 00100 fwd 127.0.0.1,9418 tcp from me to github.com dst-port 9418&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
and when you are done, don&amp;#8217;t forget to remove it:&lt;br /&gt;
&lt;pre class=&quot;console&quot;&gt;&lt;code&gt;sudo ipfw delete 00100&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
(use caution, especially if you are using ipfw already and have rule 00100 in place)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Stuck behind a corporate firewall? &lt;a href=&quot;http://blog.codeslower.com/2008/8/Using-PuTTY-and-SSL-to-securely-access-GitHub-repositories-via-SSH&quot;&gt;Justin Bailey&lt;/a&gt; has a good guide. Scroll down for a *nix solution as well.&lt;/p&gt;</body>
  <created-at type="datetime">2008-04-15T08:46:54-07:00</created-at>
  <id type="integer">32</id>
  <permalink>how-to-clone-from-github-with-ssh-tunnels</permalink>
  <title>How to clone from github with ssh tunnels</title>
  <updated-at type="datetime">2009-02-03T09:15:25-08:00</updated-at>
  <user-id type="integer">49715</user-id>
</guide>
