Using git versioning to keep track of your UNIX settings in `/etc/`

Simple idea: Using git's versioning and remote capabilities to keep track of your settings in /etc/. Why?

  • you can view diffs on settings
  • revert settings / states
  • cherry pick different configuration states
  • using branches to test configurations und environments
  • using remote repositories to sync and merge settings
  • manage (remote) backups

The following steps require root privileges.

First we need to init a git repository:

  $ cd /ect/
  $ git init .

Optional: add a .gitgnore to exclude specific and temporarily files and folders:


# temporary files which can be created if a process still has a handle open of a deleted file

# KDE directory preferences

# Linux trash folder which might appear on any partition or disk

We add all files and create a first commit:

  $ git add --all .
  $ git commit -am "initial commit"

Chronological commits

An easy way to ensure that we add regular commits is to create a cronjob with:

  $ crontab -e
  0 6 * * * cd /etc/ && git add --all . && git commit -am "automatic commit on $(date)"

Remote backups

Remote backups can easily be done by git push --all origin master.

Further tools

If you prefer additional software tools helping you, try out etckeeper (thank to Pedro for the hint).