46 lines
1.4 KiB
Markdown
46 lines
1.4 KiB
Markdown
# 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
|