How I keep all my config files under version control

December 15, 2007 at 03:05 PM | Uncategorized | View Comments

Ah, a Saturday morning that I should spend studying for my exam on Wednesday... What better thing to do than get all my important config files under version control?

Executive summary

To get all my config files under version control, I:

  1. Moved all my important config files to ~/.config/
  2. Put ~/.config/ under version control
  3. Wrote a script to make links from ~/.config/* to the Right Place (ie: ~/.config/vim -> ~/.vim)
  4. All my machines are in sync :-)

So, the problem: I use three machines on a regular basis (my laptop, my server, my computer at work). I want to keep all my important config files in sync (ie: Bazaar and Vim). I'd also like to keep them under version control (version control is a good thing, right?) Can both happen at once? Well, with the magic of bzr (or your favourite distributed version control tool), it turns out they can :-)

The first step was to collect everything into one place. I moved the files I'm going to care about (in this case, ~/.vim, ~/.vimrc and ~/.bazaar) into ~/.config and put that under version control: cd ~/.config; bzr init; bzr add * (it's worth noting that I had some problems with a couple of the bzr plugins which were under version control... Bzr didn't want to add them to my repository because they themselves were repositories. That problem was fixed with a quick rm -r <plugin>/.bzr though).

The next step was replacing the old config files with links to the new (versioned) ones. That was nothing a simple shell script couldn't solve, though (take a look at if you're interested in now it works).

Beautiful. Everything is versioned, I've just got to distribute it.

Bazaar (and just about every other distributed VCS out there) has some wonderful facilities to push/pull it's repositories. All it took was a quick bzr push s to move it over, then sshing over, checking out the files and installing the links:

  $ ssh
  $ cd .config
  $ bzr co .
  $ ./install_links

Finally, I put a link to the repository in a web-facing directory ( so I could grab it from my work machine using bzr get ~/.my_config (I have to use ~/.my_config because some program (I suspect XFCE) is using ~/.config).

And that's all there is to it :-)

Permalink + Comments