Note on tracking dotfiles across multiple instances easily with git
Came across fast.ai’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
1git init --bare $HOME/.cfg
2alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
3config config --local status.showUntrackedFiles no
4echo "alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'" >> $HOME/.bashrc
5
6git remote add origin https://repo/path/to/dotfiles.git
Add your dotfiles for example neovim and tmux:
1config status
2config add ~/.config/nvim/init.vim
3config commit -m "add neovim"
4config add ~/.tmux.conf
5config commit -m "add tmux"
6config push
Install on/migrate to new system
1echo "alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'" >> ~/.bashrc
2source ~/.bashrc
3echo ".cfg" >> .gitignore
4git clone --bare git@github.com:fastai/dotfiles.git .cfg/
5config checkout
6config config --local status.showUntrackedFiles no
Can customize by adding additional stuff like plugin managers Vundle or Plugged
1# vim-plug
2## neovim
3curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
4 https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
5
6## vim
7curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
8 https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
9
10# Vundle
11git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim