Track changes in '/etc' with git

From openSUSE

I wanted to have a good history of the changes happening/done to my '/etc'-directory. That time I played with git and did this:

cd /etc

git init .

This adds an empty repo (.git folder).

cat > /etc/cron.hourly/hourly_etc_git

#!/bin/bash

MYDATE=`date`

echo "etc_git - $MYDATE" | tee -a /var/log/etc_git.log

pushd /etc

git add . | tee -a /var/log/etc_git.log

git commit -m"$MYDATE" | tee -a /var/log/etc_git.log

popd


CTRL-D


cd /etc

git add . git commit -m"Initial /etc commit"


cat > /etc/.gitignore

mtab

texmf

ld.so.cache

asound.state

resolv*

adjtime

CTRL-D



Now the changes are recorded hourly (should be quite enough). I can watch the history like this:

cd /etc

gitk


And I can recover old values using git commands.