views:

88

answers:

1

So I've got a pretty customized setup of dotfiles at this point, and I've been looking for a solution to keep things synchronized from machine to machine. I like the idea of having a ~/dotfiles dir (or similar) that contains a makefile that handles creation of symlinks. Move the dotfiles dir from machine to machine via rsync/unison/dvcs/whatever, and I'm good to go.

The problem with this occurs because the files differ slightly on some machines, and I would like a way to track this. For example, my .xmobarrc (a panel application for those not familiar), has a configuration setting to display battery life on my laptop, but not on my desktop.

What is the best way to manage files with per machine differences like this, in such a way that if I change on one machine something that should affect all machines, I can merge back, and if I change on one machine that shouldn't get merged, it won't. Obviously a DVCS like git is necessary for this as opposed to rsync/unison/etc, but I'm not sure how to set this up.

Master branch with one branch per machine that I merge/rebase/cherry pick back and forth from? This seems a bit tedious. Is there a better way?

+2  A: 

One way would be to have:

  • a global config with all global parameters (if you change it and merge it back, it would affect all machines)
  • one config file per machine (named for instance after the machine uname)
  • a script building your final config file as the composition of the global one and the machine-based one.

Considering merges:

  • When you merge config files from one branch to another, you can merge everything (no cherry-picking involved)
  • Or you do not always have to have a branch per machines, since the machine-based config files already ensure separation and isolation of those parameters (in different files instead of different branches)
VonC