Etckeeper

From the etckeeper website:
 * etckeeper is a collection of tools to let be stored in a git, mercurial, bazaar or darcs repository. This lets you use git to review or revert changes that were made to . Or even push the repository elsewhere for backups or cherry-picking configuration changes.
 * It hooks into package managers like apt to automatically commit changes made to during package upgrades. It tracks file metadata that git does not normally support, but that is important for, such as the permissions of.
 * It's quite modular and configurable, while also being simple to use if you understand the basics of working with version control.

Emerge
Install

Additional software
etckeeper supports the following version control systems:
 * git

Files
The main configuration file is. Following configuration options in the main configuration file need specific settings:

Cron
The cron job is enabled by default, to disable it, uncomment following configuration entry:

systemd
To enable the systemd timer, run:

Usage
To add interesting files of the directory to the repository, run following command: Command used below creates a file in the  directory. If a file already exist then the content inside a "managed by etckeeper" comment block will get updated. It sets up pre-commit hooks. This command does not commit files, but does all interesting files for an initial commit later.

Using the command credentials of the user will be stored in the repository:

Before initial commit inspect the files added to the repository f.e. the shadow file

Remove not interesting files from the repository

Add not interesting files to the file

Finally commit all changes in to the repository. A commit message can be specified. It is possible to use the underlying VCS to commit manually. Note that etckeeper commit will notice if a user has used or  to become root, and record the original username in the commit. At this time it is recommended to use the git-commit command.

If the initial version has been commited, from this time forward it is safe to use following command below to commit diffs:

or:

Pack git repository to save disk space:

Troubleshooting
(Troubleshoot issues in this section. Separate issues by best describing the error with a new section name. Remove if no issues are known.)

Removal
Following commands deletes the directory:

Uninstall etckeeper:

External resources

 * README