Git-based dotfile management without symlinks
- Published at
- Updated at
- Reading time
- 1min
My dotfiles are powering multiple machines, and overall I've been happy with them. They include hand-written shell scripts to create symlinks, download all desktop apps and CLI tools, and get my preferred system settings in place. But overall, they've become a Frankenstein over time because many random scripts are doing random things. And obviously, I failed to document what's going on properly.
Sure, scripts have to run to install stuff, but for config file management, most solutions I've seen seemed too complicated to keep some files in sync. And I really don't want to use a dotfile framework to pull some configuration files.
What if there is a way to tweak Git and track all the
and config
files?
"Dotfiles management" describes Git magic to track all files somewhere on your machine from a single
repository. Yes, your read that right. Any file and anywhere.
alias dotfiles='git --git-dir=/home/mx/.dotfiles --work-tree=/'
That's right; there's a
folder somewhere on your machine (/home/mx/
in the example), and it'll track all the files no matter where they're located, thanks to the --work-tree
argument. Then there's no symlink dance!
With some additional configuration, you can add and sync files across machines without scripts using dotfiles add
or dotfiles commit
. It's all just plain Git.
This dotfiles approach is by far the smartest I've seen, and I'll definitely give it a shot when I fiddle with my system config the next time.
Join 5.5k readers and learn something new every week with Web Weekly.