Download your favorite Linux distribution at LQ ISO.
Go Back > Blogs > jheengut
User Name


Rate this Entry

restoring the configurations of a GNU/Linux system with git

Posted 11-18-2015 at 01:16 AM by jheengut

As a Slackware user, I tend to customise my configurations file a lot, ie the files in /etc. I try to avoid using programs that write into /etc, this helps to have a certain consistency among my configured files. This also has the advantage to understand and optimise for performance and speed while leveraging the work load to a minimal effect.
In view of this methodology, I proposed to myself to setup up a git repository hosted under /etc and I performed this action on all three of my computers which are all now running Slackware x86_64.

cd /etc
git init
So for every change in /etc, I performed an analysis and registered the change in git.

cd /etc
git status
git add "The necessary files"
git commit -m "The change that happened"
This step has to be taken whenever an upgrade or a patch has to be installed.

I always keep /etc updated under git. But on a reboot, new network connection using Networkmanager and automatic update of time using ntpd , this is what comes out of a git status:

 git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#       modified:   adjtime
#       modified:
#       modified:   mtab
#       modified:   random-seed
#       modified:   resolv.conf
no changes added to commit (use "git add" and/or "git commit -a")
It has been more than two years that I track my changes when Slackware 14.1 was released and I wanted to quantify the changes happened during an OS upgrade, There was not changes since at that time and on that particular SlackBox I was using Slackware -current, so no great changes was registered. But in the coming months Slackware 14.2 shall be released and it shall be a good moment to act on the quantisation process of tracking configuration changes.

Nonetheless, the git repo has saved me time to reconfigure the system when I was testing the Nvidia driver directly rather that using Bumblebee. By removing and reinstalling all packages, I lad lost all my custom configurations done upon the /etc files and directories.
The solution obviously was to use git checkout to restore all files to the last commit.

cd /etc
git status
git checkout
git status
Obviously, I cheated here. I also launched gitk and did a "git reset master branch to here". This was equivalent to a git reset --hard "commit id". This was much easier and quicker than to find the last commit, then hard reset to that particular commit.

To my surprise there were a high number of new files in /etc when performing git status. Fortunately, they consisted only of *.orig and *.new and some backup files, ie *~. So the files were then removed using find.

find . -iname "*.orig" -exec rm {} \;
git status
find . -iname "*.new" -exec rm {} \;
git status
find . -iname "*~" -exec rm {} \;
git status
Posted in Uncategorized
Views 2042 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 10:05 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration