I was struggling to keep my dotfiles in GitHub in sync with the dot files in the $HOME directory. But now it is so smooth.
Cut to the chase, here is what I do:
The $HOME folder will be the single source of truth. I keep all the original files here
Use rsync to sync all the files from $HOME to dotfiles Github local repo
Commit the files to the origin to backup.
You may have many files so you may have many rsync commands, let pack it into a bash function and add it to your ~/.zshrc
dotsync() {
rsync -r ~/.config/nvim/* ~/projects/dotfiles/nvim
rsync -r ~/.config/karabiner/* ~/projects/dotfiles/karabiner
rsync -r ~/.config/kitty/* ~/projects/dotfiles/kitty
}
My dotfiles repo is public here https://github.com/finnng/dotfiles
There are a lot of benefits to this approach
My dotfiles repo is pristine since the file itself is the single source of truth
No more linking issues like sometimes you have to force linking with
ln -fs
Stress-free, no more file conflict, let the rsync command deal with it.