Building notes, projects, and occasional rants


Managing dotfiles

I use a simple bit-based setup inspired by this HN thread. A more step-by-step tutorial can be found in The best way to store your dotfiles: A bare Git repository.

I keep all my dotfiles in a bare git repository under $HOME/.dotfiles, and have a bash alias named dots to manage it.

This is my third attempt. The first was a homebrew solution that kept symbolic links to a git repository. The second used GNU Stow to manage the symbolic links. See Using GNU Stow to manage your dotfiles for an example workflow if you decide to use this method.

I’ve switched to this setup because it doesn’t require the use of symbolic links.


Run this once, on your main workstation, to start using this system:

git init --bare $HOME/.dotfiles
dots='alias dots="git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME"'
comp='complete -F _git dots'
echo "$dots" >> $HOME/.bash_profile
echo "$comp" >> $HOME/.bash_profile
eval $dots
eval $comp
unset dots comp

Mostly straightforward stuff, but I’ve also borrow the standard git bash completion function for dots commands with the last line. This requires that bash completions for git is already setup by the time you do this…

Setup on a new server

When you get to a new server, use this process to start with a copy of your dotfiles:

git clone --separate-git-dir=$HOME/.dotfiles <you_repo_location> my-dotfiles-tmp
rsync -av --exclude '.git' my-dotfiles-tmp/ $HOME/ ## this will overwrite any files with the same name!!
rm -rf my-dotfiles-tmp

The rsync step is required because git clone refuses to clone a repository into a non-empty directory:

$ git clone --separate-git-dir=$HOME/.dotfiles ~
fatal: destination path '/Users/melo' already exists and is not an empty directory.

Keeping your dotfiles updated

To update the dotfiles from time to time:

dots pull


Just use git

config status
config add .vimrc
config commit -m "Add vimrc"
config push

Other resources

Links to set of dotfiles I used overtime: