paapereira.xyz

Manage dotfiles using a git bare repository

I’ve been searching the best way to manage my dotfiles using git.

After seeing this video and checking this tutorial I decided to give it a go.

I will be using keybase as my (private) git repository.

Create and setup repository

1mkdir -p $HOME/.dotfiles
2git init --bare $HOME/.dotfiles
3alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME'
4dotfiles config --local status.showUntrackedFiles no
5echo "alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME'" >> $HOME/.zshrc

Adding files

1dotfiles status
2dotfiles add .vimrc
3dotfiles commit -m "Add vimrc"
4dotfiles remote add origin keybase://private/your_username/dotfiles
5dotfiles push -u origin master
1dotfiles add .bashrc
2dotfiles commit -m "Add bashrc"
3dotfiles add .zshrc
4dotfiles commit -m "Add zshrc"
5dotfiles push

Dotfiles in a new system

 1alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME'
 2echo ".dotfiles" >> .gitignore
 3git clone --bare keybase://private/your_username/dotfiles $HOME/.dotfiles
 4dotfiles config --local status.showUntrackedFiles no
 5mkdir -p $HOME/.dotfiles-backup
 6dotfiles checkout
 7if [ $? = 0 ]; then
 8  echo "Checked out config.";
 9else
10  echo "Backing up pre-existing dot files.";
11  dotfiles checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} mv {} $HOME/.dotfiles-backup/{}
12fi;
13dotfiles checkout
1dotfiles pull

#Linux #Arch Linux #Git #Tags/Keybase