Keeping your environment in GIT

What inevitably happens sooner or later is that I have to reinstall a Linux machine and set up its environment to what I am used to, so I can do some serious development work on it. I have pages describing how I set up Linux on my workhorses and how for example I I get a TFTP server going. Of course I also have a bunch of gits that contain my different projects. But what about all these basics: .bashrc, .gitconfig, .emacs (or whatever you use) and my $HOME/bin where I keep all my cool bash scripts?

People have tradtionally just copied these files over and made some local modifications to them on every machine, and if the harddisk crash or they get a new machine, painstakingly restore them from backups or rewrite/copy them, sometimes an older version even. I had it with loosing valuable know-how like that.

My solution is to put these files in a separate git, and prime the system before first use. That way I always have the configuration I want and I can quickly set up a system with all the stuff I need.

To do this I create a git called scripts.git and put on a private git server, access from SSH. Since this is my uglyhacks, backup scripts etc it's not generally useful, but I can give you a general image of what its structure is like, and I provide a skeleton git for you to use.

Here is a demo git on GitHub that you can clone for starters.

Here is how it looks:

  $HOME
  |
  +- scripts
  |  +- dotbashrc
  |  +- dotemacs
  |  +- dotgitconfig
  |  +- bin
  |  |  +- createbackup.sh
  |  |  +- fnord.sh
  |  +- etc
  |     +- exclude-from-backup
  |     +- foo-crontab
  |
  +- .bashrc -> scripts/dotbashrc
  +- .emacs  -> scripts/dotemacs
  +- .gitconfig -> scripts/dotgitconfig
  +- bin -> scripts/bin
  +- etc -> scripts/etc

So as you see I have:

What you need to think of is that whenever you made some ingenious change to one of your configs or scripts, just git add, git commit and git push like with any other development.