I have recently come accross with a new solution to one of my biggest headaches in any linux system and it is to manage the nightmareof the dot files. I have previously used stow in order to mantain the symbolic links, but there is a much better solution using git bare repositories.
- Create a git bare repository with the following line
mkdir $HOME/.dotfiles
git init --bare $HOME/.dotfiles
- Create an alias for a better managing of the configuration
alias dc='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
It should be highlighted that you can put it in your .bashrc or the file you use for your alias, in my case $HOME/.config/aliasrc
- Disable the tacking of any single file
dc config --local status.showUntrackedFiles no
- You can use it in a normal basis with config and keywords like "add, delete, status, checkout, ...". Remember to add a remote repositoryy with this lines
dc remote add origin <remote-url>
dc push -u origin master
For example you can create a diferent configuration in different branches for each machine that you have.
- Prevent weird circular dependencies
echo ".dotfiles" >> .gitignore
- Clone the remote repository
git clone --bare <remote-git-repo-url> $HOME/.dotfiles
- Restore the alias and configuration of tracking
alias dc='/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME'
dc config --local status.showUntrackedFiles no
- Proceed to checkout
dc checkout