Create a .dotfiles
folder, which we'll use to track your dotfiles
git init --bare $HOME/.dot
Create a dot
alias that uses .dot
as the git repository and your $HOME
as the working directory.
Make sure to add it to your .bashrc
or .zshrc
alias dot='git --git-dir=$HOME/.dot --work-tree=$HOME'
You can now use dot
to manage any file in your home directory.
Add .dot
to .gitignore
to prevent weird recursion issues.
echo ".dot" >> .gitignore
Clone your dotfiles in a bare git repository.
git clone --bare git@github.com:folke/dot.git $HOME/.dot
Define the alias
alias dot='git --git-dir=$HOME/.dot --work-tree=$HOME'
Checkout your dotfiles!
dot checkout
If you get errors about existing files, back them up first and retry
mkdir -p .dot-backup && \
dot checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | \
xargs -I{} mv {} .dot-backup/{}