Oliver Nassar

Creating a simple Git Server on Ubuntu 12.04

November 19, 2012

After upgraing to OSX Mountain Lion, I discovered something surprising: it doesn't come with svn installed. This seems like as good of a time as any to switch some repo's over to git.

There is a way to get around this, naturally, which includes downloading Xcode. I'm not a fan of installing huge libraries like Xcode if I don't need to, so may as well move on to git, which comes compiled in with OSX.

So, here are the steps to get a repo up and running on my server:

cd
sudo mkdir /srv/git
sudo chown ubuntu:ubuntu /srv/git
mkdir /srv/git/project.git
cd /srv/git/project.git
git --bare init
cd

Just like that. These steps came from a great blog post titled Git - Setting Up the Server.

My server wasn't set up with passwordless login. Rather, it was based on specifying a key. To get around this, I copied my public key (view it by issuing the command cat ~/.ssh/id_rsa.pub) into my server's ~/.ssh/authorized_keys file.

From there, I could check out my new git repo like so:

git clone ubuntu@ip_address:/srv/git/project.git

Hopefully this all helps someone.
I'm sure this will serve as a nice reminder for me later on :-)