From 8a6198ecaf56e6d08ad42df937e016bb2a098e50 Mon Sep 17 00:00:00 2001 From: Jonathan Agmon Date: Sun, 22 Mar 2026 23:31:46 +0200 Subject: [PATCH] Add dotfiles.md --- linux/dotfiles.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 linux/dotfiles.md diff --git a/linux/dotfiles.md b/linux/dotfiles.md new file mode 100644 index 0000000..71c913d --- /dev/null +++ b/linux/dotfiles.md @@ -0,0 +1,45 @@ +# Dotfiles Management +## Create new bare repo +### 1. Initialize a bare repo in your home directory +git init --bare $HOME/.dotfiles + +### 2. Create an alias (add this to your .bashrc / .zshrc) +alias config='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME' + +### 3. Hide untracked files (so 'config status' isn't noisy) +config config --local status.showUntrackedFiles no + +### 4. Start tracking files +config add ~/.config/nvim/init.lua +config add ~/.config/alacritty/alacritty.toml +config commit -m "Add nvim and alacritty config" +config push + +## Clone to a new machine +### Clone repo +git clone --bare https://github.com/you/dotfiles.git $HOME/.dotfiles + +### Set up the alias again, then checkout +alias config='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME' +config checkout + +### If there are conflicts with existing files, back them up first +mkdir -p ~/.config-backup && \ +config checkout 2>&1 | grep "\s\+\." | awk '{print $1}' | \ +xargs -I{} mv {} ~/.config-backup/{} +``` + +## Key Principles + +**What to track selectively** — don't blindly add all of `~/.config`. Be intentional: +- ✅ App configs you've customized (nvim, tmux, git, zsh, etc.) +- ❌ Secrets, tokens, credentials (use `.gitignore` or a secrets manager) +- ❌ Cache dirs (`~/.config/*/Cache`, `~/.config/*/logs`) +- ❌ Machine-specific state files + +**Use a `.gitignore`** at `$HOME` level: +``` +.config/*/Cache +.config/*/cache +.config/**/sessions +.config/chromium # browser data