Github – the ‘wrong’ way around – Putty + Github

So, as many of you know, Github is a popular place to upload your code repositories to. Most people go to Github and create their repository, download it, hack on it, and push/pull request back to it.


But what if you don’t want the project to live on Github? After, Git is a decentralized protocol – making github the centralized repository for your projects is antithetical to the way git is actually supposed to work. For the purposes of this tutorial, I will be using putty, but this is completely optional if you wish instead to use openssl.


Unfortunately, unless you are a git pro, its not always obvious how to truly decentralize things. So, I’m writing up a guide for users (including a future me) on how to do this.


First thing is to create your project. Flesh out the structure, get it working, and compiling, or just create a directory with nothing it. It doesn’t matter a whole lot. Then, run:

git init

Now, ‘provision’ your project on github. Sign into your account, create yourself a project. Be careful – Github will ask you to add a license and a description. You don’t have to do this, but if you you will have to merge these files in with your local project. This is nothing scary, but it could mean some more busy work for yourself, so I advise against doing this.

Once you have your project provisioned, grab the git-ssh url, do not grab the https url , and run:

git remote add github

where is replaced with your url.

Optionally, you can setup branch tracking, but to keep this as decentralized as possible we are going to leave this completely untracked.

Now, generate yourself an SSH Key – puttygen will do this for you – and upload the public, not the private to the github account.

Here comes the important step – it appears github is rather broken, so we must ssh into the server in order to accept its key in putty. First, add your key to your pageant (just run it, open it up in the tray, and click ‘add-key’). Then, open up putty, and paste the url you used before, and connect. Accpet the connection, and voila, you can now access github via ssh keys. Bit of a roundabout process, eh?

To actually perform a push, do the following:

git pull github master

git push github master:master

The nice thing about this, is you can now push a project to multiple git repos – not just github, but your own personal servers, sourceforge, google code, Atlassian’s Stash, bitbucket, etc. You are no longer a slave to any one repo!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s