Dotfiles

2019-12-23

I track various text config-files in my home-directory in a Git repo. My setup is pretty much the same as what’s described on the Arch Wiki - I didn’t invent anything, but I wanted to write down what my setup is.

Initial setup

I’m hiding the repo in my .config folder - it’s a ‘bare’ repo, and I have aliases set up to use my home-directory as the work-tree:

git init --bare $HOME/.config/repo
alias config='/usr/bin/git --git-dir=$HOME/.config/repo --work-tree=$HOME'
config config --local status.showUntrackedFiles no

Then follow whatever instructions you need to wire up the repo to a remote (except substitute config for git in the instructions).

(The above alias is also set up in my shell rc files.)

Workflow

I then work with the ‘config’ alias as if it where the ‘git’ command-line program:

config status # see what's different
config diff   # see what's different in detail
config add    # track new dotfiles
config commit -am "change message"
config push

Checking out to a new machine

On a new workstation (this is similar to the initial-setup phase, but a checkout instead of an init):

git clone --bare $RepoUrl $HOME/.config/repo
alias config='/usr/bin/git --git-dir=$HOME/.config/repo --work-tree=$HOME'
config config --local status.showUntrackedFiles no

(the alias will also need to be added to shell rc files)

Review any local differences with what’s tracked in Git:

config status
config diff

Then either config checkout or config add -p as appropriate (and then do a commit/push if you want to keep any of the changes.