My dotfiles have been a mess for years and I finally did something about it. The state of play was the usual entropy: a .zshrc that had grown by accretion, aliases I couldn't remember adding, a vim config copied piecemeal off the internet circa 2014, and three machines all subtly different because I'd fix something on one and never propagate it. Every new box meant an hour of half-remembering what I liked and reconstructing it badly. It works, until you get a new laptop, and then you realise how much of your comfort lives in files you never backed up.
The fix is the one everyone arrives at eventually: put the lot in git. The bit that took me too long to discover is the cleanest way to track dotfiles in place, which is a bare repository with the work tree pointed at your home directory. No symlinks, no copying files into a repo and back out, no tool to install. The files live exactly where they belong and git tracks them where they sit.
git init --bare $HOME/.dotfiles
alias dot='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
dot config --local status.showUntrackedFiles no
That showUntrackedFiles no is the trick that makes it usable. Your home directory has thousands of files you don't want tracked; this stops dot status drowning you in them. You explicitly dot add the few you care about and ignore the rest. From then on it's just git: dot add .zshrc, dot commit, dot push.
The other half is a bootstrap.sh that turns a fresh machine into a comfortable one in a single command. Clone the bare repo, check out into $HOME, install the handful of tools I actually rely on, done.
#!/bin/bash
set -euo pipefail
git clone --bare https://example.com/me/dotfiles.git "$HOME/.dotfiles"
dot() { git --git-dir="$HOME/.dotfiles/" --work-tree="$HOME" "$@"; }
dot checkout
dot config --local status.showUntrackedFiles no
There's a real chance checkout complains that it would overwrite an existing .bashrc or similar on a fresh-but-not-empty box. The honest answer is to back the offenders up and move them aside, then check out again. I added a couple of lines to do exactly that rather than pretend it never happens.
What I deliberately didn't do is reach for a dotfiles manager. There are good ones, and for a setup with lots of machine-specific templating they earn their place. Mine isn't that. It's a dozen files I want to be the same everywhere, and a bare git repo handles that with zero dependencies and nothing to learn beyond git, which I already know. Fewer moving parts, fewer things to break on a machine where I'm trying to get other work done.
The payoff landed sooner than expected. I set up a new box last week and it went from stock to home in about two minutes: clone, bootstrap, open a shell, and there were all my aliases and my prompt and my editor, exactly as I'd left them on the laptop. After years of reconstructing my environment by hand and getting it slightly wrong each time, that was a genuinely small joy. Should have done it ages ago. Most good housekeeping is like that.