Note on tracking dotfiles across multiple instances easily with git

Came across’s dotfiles repo, which provided gems of insight into managing dotfiles in Linux (and Windows WSL) environment by using git bare repos. The repo also provided a very good quick start for some common command line configs. When you are working on various compute instances on cloud and/or on local, it is very handy to track and transfer dotfiles easily.

From scratch

Create an empty repo on Github/Bitbucket/Gitlab named dotfiles

git init --bare $HOME/.cfg
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
config config --local status.showUntrackedFiles no
echo "alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'" >> $HOME/.bashrc

git remote add origin https://repo/path/to/dotfiles.git

Add your dotfiles for example neovim and tmux:

config status
config add ~/.config/nvim/init.vim
config commit -m "add neovim"
config add ~/.tmux.conf
config commit -m "add tmux"
config push

Install on/migrate to new system

echo "alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'" >> ~/.bashrc
source ~/.bashrc
echo ".cfg" >> .gitignore
git clone --bare .cfg/
config checkout
config config --local status.showUntrackedFiles no

Can customize by adding additional stuff like plugin managers Vundle or Plugged

# vim-plug
## neovim 
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \

## vim
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \

# Vundle
git clone ~/.vim/bundle/Vundle.vim