Creating a Git repo at / (root) for tracking settings?

So I use Git mostly for development purposes, but I just realized that I could use it for storing versions of the settings files I have on my Ubuntu installation.

My proposed setup is:

  • git init a repo at /

  • Add a .gitignore at / that ignores any files except specific settings I want to track.

    For example, the .gitignore could contain (source):

    ## Ignore everything...
    *
    
    ## Except...
    !/etc/default/tlp
    !/etc/crontab
    
  • Whenever I change these low-level settings, I can track them.

Is there anything that could go wrong with this setup? Does the kernel always need / to only have certain folders? Will it mess up the functioning of any applications?


Solution 1:

The answer to both of your questions is no, you can create any directory you want in the /. the only thing that could happen is some permission issues with some spacial paths I guess.

However it's better to store the .git directory somewhere else, something look like:

git --git-dir=/home/user/backup-root --work-tree=/

Read here.

Solution 2:

Actually, you probably want to version control configuration files in /etc/ (you don't care about the entries of the root directory /, notably directories like proc or usr or bin in /) so you may want to install the etckeeper package

And you could also version control some selected subdirectories (like /usr/share/applications/ that you mentioned).

However, don't mess with the Ubuntu package management system. Perhaps you mostly should backup the current list of installed packages.