My dotfiles setup is based on the instructions from this comment on HN and this blog post from atlassian.
The way this works is by creating a bare git repository and setting the work-tree to the $HOME
directory, and specifying this work-tree every time a change is made to this repo, to make this step easier an alias is defined. This allows me to keep the config files at their locations, avoiding symlinks.
git init --bare $HOME/.dotfiles
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
dotfiles config --local status.showUntrackedFiles no
dotfiles remote add github git@github.com:thlsrms/dotfiles.git
In my case, using fish
shell I add my dotfiles alias as a function in my config.fish
file.
Now git commands such as git add | commit | push
can be used to track relevant config files using: dotfiles add | commit | push
To avoid conflicts, for possibly having some default config files in the new system's $HOME
directory, the repository must be cloned to a temporary directory.
git clone --separate-git-dir=$HOME/.dotfiles https://github.com/thlsrms/dotfiles.git tmpdotfiles
rsync --recursive --verbose --exclude '.git' tmpdotfiles/ $HOME/
rm -r tmpdotfiles
dotfiles config --local status.showUntrackedFiles no