C.W.K.
Stream
Lesson 10 of 10 · published

Dotfiles Management

~12 min · dotfiles, chezmoi, stow, git

Level 0Window Tourist
0 XP0/95 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

Why version your dotfiles?

Your ~/.zshrc, ~/.gitconfig, ~/.ssh/config, and a dozen others are your computer's personality. Lose them and a new Mac feels alien for days. Keep them in git and you can replicate yourself in 10 minutes.

The plain-git approach

cd ~
git init --bare $HOME/.dotfiles.git
alias config='/usr/bin/git --git-dir=$HOME/.dotfiles.git --work-tree=$HOME'
config config status.showUntrackedFiles no
config add .zshrc .gitconfig .config/starship.toml
config commit -m 'starting'
config push -u origin main

This treats your home as a working tree but only tracks the files you explicitly add. Restore on a new Mac with the same alias plus config checkout.

chezmoi — a dedicated tool

brew install chezmoi. chezmoi init https://github.com/me/dotfiles. Files live in a separate source dir, chezmoi apply writes them to your home. Templates, secrets via password managers, OS-conditional content. The most popular dotfile manager.

GNU Stow — symlink farms

brew install stow. Organize dotfiles in a ~/dotfiles/zsh/ tree mirroring home; stow zsh creates symlinks from ~/.zshrc back into the repo. Light, no template engine.

What to track, what not to

  • Track: .zshrc, .gitconfig, .ssh/config (no keys), .config/{starship,nvim,fish}, .vimrc, .tmux.conf, .editorconfig, .gitignore_global.
  • Skip: .env, .ssh/id_*, .ssh/known_hosts, anything in .cache, .npm, .pyenv, .docker. State and secrets aren't config.

Pippa pattern

The Pippa fleet keeps an office-Mac-as-source-of-truth model. Office writes new dotfile changes; peers fan out via fleet-deploy scripts that verify with sha256. The principle is the same as chezmoi: one repo, many machines, idempotent restore.

Code

Quick chezmoi setup·bash
brew install chezmoi
# Add an existing dotfile
chezmoi add ~/.zshrc
# Edit the source
chezmoi edit ~/.zshrc
# Apply changes back to home
chezmoi apply
# Push the source repo to github
chezmoi cd

External links

Exercise

Pick chezmoi or plain-git. Initialize. Add .zshrc and .gitconfig. Push to a private GitHub repo. Then on a second machine (or a fresh user), restore from the same repo. Time it — 10 minutes is the goal.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.