GitHub is awesome! We all know that. But why would you keep private projects on GitHub if you’re not an enterprise user? I’ve seen a lot of people use GitHub as their only repository host and when GitHub goes down they’re screwed. Worse, I’ve seen people try to keep private repos on GitHub without paying by using some ridiculous closed source license like that’s going to stop someone from cloning your publicly available repository. Don’t you know, Git is different than GitHub? Don’t you know that regular Git without the Hub works exactly the same?
Well, minus the UI. But in a lot of cases you just don’t need that. GitHub is great for sharing code with others and collaborating but when it comes to private stuff you have options. If you’re building someone that’s not meant to be shared just host it on your own server. If you’re using Git you’re most likely comfortable in the terminal and you probably have access to a non-shared-host server somewhere. Well install Git and use it for your private repos like I do! Here’s how.
I host all my projects that are not meant for public consumption like Write.app and others on my own server. I also host spare mirrors of GitHub repositories there too in cases where I want to push to a remote but the code isn’t ready for the public and just as a backup for when GitHub is down. It’s super easy and you lose nothing but the website part of GitHub. My server runs Ubuntu 12.04 so some of these instructions may be a teeny bit different.
Set up a repo space
I use my home folder to store Git repositories. I have a special
git folder which is almost exactly like my local
~/Sites folder except instead of hosting websites and other code it hosts repositories.
Now, let’s make a repo. Let’s say we’re working on an awesome Rubygem that uploads stuff to S3. Let’s say it’s called Sploder. Well, we already have it on GitHub but let’s mirror it. So on our local machine we’d…
1 2 3
Now let’s make sure that exists on our server too. Log into your server and run…
1 2 3 4 5
Okay, back on our local machine…
1 2 3
And BAM! That’s it. That’s how you self-host a repo. No need to litter your GitHub account with projects no one cares about. Do everyone a favor and keep your GitHub clean so when someone browses your repository (and they do even if you don’t think so) they don’t have to sift through a million projects trying to figure out which ones are worth checking out because now they’re all worth checking out because you only host the cool stuff you want to share on GitHub now.