Managing /etc/ using git

The directory /etc/ is vital for our Linux systems as it contains (most of) the configuration files of the system. In case of trouble, it’s quite common, that you’ll visit this directory after browsing through syslog. Sometimes it would be nice to be able to really track down changes to see what happened over time; and this is where git comes in handy.

First, create the repository and secure it:

git init-db
chmod og-rwx .git

Then it’s time to worry about files we don’t want to track. We list them in .gitignore. Mine looks like that:


If you didn’t set up the git client (Name, mail,…) it’s the right moment to do that before we start working:

git config –global “Your Name Comes Here”
git config –global
git config –global color.diff auto
git config –global color.status auto
git config –global color.branch auto

Now let’s do an initial import:

git add .
git commit -a -m “initial import”

Now as soon as changes are made, it’s time to commit them:

git commit -a

If you would like to know which files changed since your last commit, you can get a list:

git status

in case you need to see the exact changes, diff comes in handy:

git diff

If you do not want to track certain files anymore, just add them to .gitignore and kill them from the cache using the following command:

git rm –cached

That’s it.

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.