It’s never super clean, but this does speed me up enough to get moving quickly. I’ve considered
setting up a more global
$HOME sync folder with a ton of excludes, but I want to be a bit more
intentional about updating my system configuration.
I decided to just use a private GitHub repo to store these dotfiles, taking a lot of care to avoid committing any secrets (I like to assume that anything I store on someone else’s computer will eventually be public).
This turned out to be so much easier than I expected, just a simple alias to override the
and a custom exclude file to make sure I only add very specific files to this repo.
git init --bare $HOME/.cfg echo "*" >> $HOME/.cfg/info/exclude alias dotfile="git --git-dir=$HOME/.cfg/ --work-tree=$HOME"
I have the above alias added to my
.zshrc (so bonus: it is automatically sync’d!) and can do all
git commands by calling
dotfile remote add origin email@example.com:private/repo.git dotfile add .gitconfig dotfile add .zshrc ... # etc dotfile commit -m 'add my dotfiles' dotfile push -u github main
Now, to setup a new machine, I need to setup my dotfile repo in my home directory. Just as before
when I initialized a bare git repo with a custom
GIT_DIR, I need to clone my repo on the new
system with the bare flag and pointing to the same
.cfg directory for consistency. You can test
this non-destructively by creating a temporary folder and referencing it instead of
$HOME in the
⚠️ This will overrwrite any tracked files in
git clone --bare firstname.lastname@example.org:private/repo.git $HOME/.cfg git --git-dir=$HOME/.cfg --work-tree=$HOME checkout -f
Now I can do things like manage OS-specific entries and files via branches, or try out major changes without worrying about leaving myself in a broken state on this machine or another one.