adapted from this guide
Store dotfiles in a bare git repo
Create a bare git repo in your home folder (or anywhere) which will store the refs for all your dotfiles:
git init --bare $HOME/.dotfiles
Create an alias for managing your dotfiles from anywhere on the system, using an absolute reference to the repo you just created:
alias dot='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
Add this alias to your
.zshrc or whatever.
Configure the repo to ignore untracked files:
dot config --local status.showUntrackedFiles no
Now you can commit dotfiles to the repo:
dot add .vimrc && dot commit -m "Add vimrc"
If you make modifications to tracked files, you can quickly commit them with:
dot add -u . && dot commit -m "update some dotfiles"
This only stages and commits files which are already tracked.