into the wonderful…

Version controlling your own local system files is nothing that I hear many people talk about. Not entirely happy with the likes of something like Time Machine for this purpose, because it only allows you to travel back and not necessarily inspect in detail and compare different versions of files, I went in and setup a nice little rig for my own Git-powered version control system for my local system files. And it works like a charm. This assumes you are using a Mac OS X environment, but your mileage shouldn’t vary much on *NIX flavours. I also assume that you use SSH profusely and already have Git installed (please refer to the millions of documents on the web if that’s not the case, and come back here afterwards).

First you need to set up your Mac to allow SSHing into it. You’ll need this to push and pull stuff from the “remote” Git server – which will actually just be your own local machine. Go to the Sharing panel of System Preferences and activate Remote Login. If you want to, you can later tighten your local SSH server, e.g., so that it only accepts connections coming from the local machine.

Having Git already installed means you already have the “server” part of it. Just create a directory where you will keep all your local repositories, wherever you feel more comfortable with:

mkdir /Users/matamouros/git

To create a new server repository you first create a directory for it and set it up for Git:

mkdir /Users/matamouros/git/etc.git
cd /Users/matamouros/git/etc.git
git init –bare

That was the server part taken care of. As for the client part, in my case I wanted to version control some files on my /etc/ dir. No problem. Go into /etc/ and do:

cd /etc/
git init git remote add origin matamouros@localhost:/Users/matamouros/git/etc.git

Next up is business as usual. If you do git status you will see all of your /etc/ dir unversioned. Just add whatever you want to Git and .gitignore the rest.

You can now commit, push, pull, etc., all your relevant local files, and have them in a nice Git repository ready for integration with your favourite Git interface like GitHub for Mac.

GitHub for Mac