04
Oct

The Secret to Github at work

Tags: git github proxy

Update: 2011-09-28 To this day this still remains one of the most popular posts on this site. However, since the introduction of smart http, this workaround is no longer necessary. You may want to keep this snippet handy though:

sed -i 's/git:\/\//https:\/\//g' .git/config

This will replace any references to the git protocol to the smart https protocol. This is especially handy for projects that use submodules such as AkitaOnRails' Vimfiles

We will now return to our regularly scheduled programming

You've been able to clone github repositories using http for a while now which allows you to get around proxies at work. But using this method won't allow you to push any changes back, which is a major pain point to using Github behind at my workplace.

Today, a co-worker brought this article from Justin Bailey to my attention, which describes how to use an ssh tunnel over port 443 to get push access to github.

The steps in the above are pretty clear and consice, however I added a few minor changes. Here are the steps I used to get it up and running.

  1. Install Putty. I used the all in one installer.
  2. As I use msysgit I renamed C:\Program Files\Git\bin\ssh.exe so that Putty's ssh was used. I also copied C:\Program Files\PuTTY\plink.exe to C:\Program Files\PuTTY\ssh.exe but I'm not sure if that is essential.
  3. Add C:\Program Files\PuTTY\ to your PATH environment variable.
  4. Use PuttyGen to create a putty comptible private/public key pair. Make sure you add this new public key to your Github account.
  5. Using PuTTY, create and save a session for github with the following characteristics:
    • Set the host to ssh.github.com, port 443.
    • Under Connection / SSH / Auth, select your private key file for SSH authentication.
    • Under Connection / Proxy, select HTTP and enter appropriate information for the host and port.
    • Save your session with a name such as “gitproxy”.
  6. Start up Pageant and load in the key you created in step 4.
  7. Clone your repository using http
  8. Edit .git/config and change the remote origin to pass through the proxy you created above.
    [remote "origin"]
        fetch = +refs/heads/:refs/remotes/origin/
        url = git@gitproxy:YOURGITUSERNAME/YOURGIT_REPO.git
    

That's it. By editing .git/config all the operations that use the default origin/master will work nicely. You can now push with a simple 'git push'.

This setup is dependant on the ssh.github.com host. Let's hope the move to Rackspace includes maintaining this useful option.


9 comments Bookmark and Share

  1. Avatar for Law Essay

    by Law Essay - Nov. 29, 2011 11:17 a.m.

    It is very nice to learn how to make good programs. I have been dreaming to become a good programmer but it so happen that programming seem not to like me.

  2. Avatar for UK Essay

    by UK Essay - Nov. 29, 2011 11:18 a.m.

    It is very nice to learn how to make good programs. I have been dreaming to become a good programmer but it so happen that programming seem not to like me.

  3. Avatar for craps tables

    by craps tables - Dec. 5, 2011 9:26 a.m.

    I was learned about this site , having a presentation to be dwell from us.

  4. Avatar for aluminum bridge

    by aluminum bridge - Dec. 8, 2011 12:39 p.m.

    Making a program is not easy. I studied it before but I failed to run my program the way it should be.

  5. Avatar for jobs kenya

    by jobs kenya - Dec. 22, 2011 5:43 a.m.

    This will surely help a lot of programmers out there.

  6. Avatar for jobs kenya

    by jobs kenya - Dec. 22, 2011 5:43 a.m.

    This will surely help a lot of programmers out there.

  7. Avatar for jobs kenya

    by jobs kenya - Dec. 22, 2011 5:44 a.m.

    This will surely help a lot of programmers out there. It indicates how important those codes are.

  8. Avatar for everett dental clinic

    by everett dental clinic - Jan. 20, 2012 2:52 a.m.

    Its been very useful to me for I have the same process with you. Thanks on the ides.

  9. Avatar for maryluo

    by maryluo - Jan. 20, 2012 6:54 a.m.

    I don't have any idea on this but because of this blog, It gave me information and idea about this thing. I am very much greatfull and its really my pleasure on reading this blog. keep it up! <a href="http://www.excelbridge.com/for-engineers/bridge-types">steel bridge</a> | <a href="http://www.excelbridge.com/for-owners/bridge-types">pedestrian bridges</a>