i Using GitHub to Sync Dot Files Between Machines, With a Twist · Dark Matter Industries

Using GitHub to Sync Dot Files Between Machines, With a Twist

Many moons ago I sat back in my desk chair with satisfaction that I had come up with a solution (independently) of sync’ing my various config and dot files with the many OSX and macOS machines that I use. Yes, I do jump between a number of them.

The solution made use of macOS’s iCloud sync. I merely created a folder called dotfiles/ in a sync’d folder (in this case ~/Documents/dotfiles/), placed all the config files in there and then just symlink’d to those files.

Then, I found myself creating more and more virtual machines off cloud platforms like GCP and AWS, and buying and tinkering with more Raspberry Pi’s. And I was back to the same problem of having to manually copy, then manage my dotfiles.

Part of the solution is something that a gazillion dev’s have been using since GitHub existed. That is, use a GitHub repo as the ground truth of these config files. Modifications made on any machine, can be pushed up to the master.

One happy twist is that I can keep my iCloud sync’d directories on my Macs. All I need do is to git init and clone the dotfiles on one machine. What happens is not only do the config files get sync’d nicely among my Darwin machines, the whole .git structure does too!

A word of caution on using symbolic linking: I have found that if I do not use explicit but instead relative paths while invoking ln -s (e.g. using ln -s ~/my/path/ or even $ZDOTDIR/my/path), I have sometimes experienced a too many levels error on Darwin.