Drew's Blog - Home - Archive

Misadventures with Gitolite, Part 1: Installing Gitolite

I've been trying to set up a Github-pages like setup that allows me to update my blog with git-push. This is the first post in a two part series on how I got there. Here's the next post.

As many of you (all 3 of you, hi mom!) know, I host my blog on S3. I started doing this before I realized Github Pages was a thing, or else I would've done it there. (I recommend that you do that, if you're looking for something low maintenance. I should also write a post on getting started there, because their documentation is also suspect.) My current workflow involves generating the site locally, and then using Cyberduck to upload it to S3, which could be simplified, so I spent some time over the past few days working on that. These posts are meant to help you replicate my setup.

The first piece of the puzzle is hosting your own git server. I'm using gitolite to manage things, as it is designed to make hosting multiple git repositories easy, especially if you want to have different access controls for multiple users across repositories. (Which I wasn't doing on my previous git server – bad Drew.) I'm also out of private repos on Github, and it's much cheaper to rent a machine on AWS than to up my cap there. (Most of the code I write is for class, so I can't open source it, but I still like offsite backups and being able to work from multiple machines.) So, without further ado:

Installing Gitolite

The first thing you should know is: don't try installing it from the gitolite package. That's a version behind, and doesn't work with the newest hook configuration (which is much better than the old hook stuff). (We need hooks to automatically upload things to S3 after we check it in.)

The second thing you should know is: I put together a script to do this! (This was mostly for future me, but maybe you, anonymous internet person, can also get some mileage out of it.) It lives here:

Before running the script, you'll need to generate a public/private keypair for authentication, and upload the public key to your server. Github tells you how to do this if you don't know, but you only need to do steps 1 and 2 and then upload your ~/.ssh/id_rsa.pub key to your git server (to somewhere where the git user will be able to read it, see the script), instead of adding it to Github.

At this point, gitolite has created an admin repo at ~/gitolite-admin.git/. You should clone this on to your home machine. (git clone git@your-server.com:gitolite-admin.git) To add new users to your system, you add <theirname.pub> to the keydir directory. To manage which repositories they can access, edit the conf/gitolite.conf file. (You also can use this file to set per-repo config variables, etc.) To create new repositories, you can push them to the remote, or you can manually create them by editing the config/gitolite.conf file. That's about it for now! Good luck!

If you've read this far, you should probably follow me on Twitter.

See more posts

Drew writes code for fun and (sometimes) profit. He's currently studying Computer Science at Carnegie Mellon University. He has previously worked at Facebook, Amazon, and a startup called Intersect.