Traditional dotfiles management is relying on keeping you repository in sync with the OS dotfiles via symlinks which is not ideal. Bare repo is solving that, because it enables us to keep the tracked files (working tree) separate from the internals (.git folder) In our case the working tree will be $HOME and the internals will be in $HOME/projects/dotfiles.git
Add in your shell config the following
export DOTFILES=$HOME/projects/dotfiles.git
#setup alias to link .git dir to $DOTIFILES and the working tree to $HOME
alias cfg='git --git-dir=$DOTFILES --work-tree=$HOME'
From now one we will use cfg
instead of git
when it comes to managing config files (dotfiles)
git init --bare $HOME/projects/dotfiles.git
Make sure that untracked files are not showing - we want to pick only what we need for git persistance
cfg config status.showUntrackedFiles no
Now edit some of your config files and cfg add <yourfile>
and cfg commit -m <message>
Now you can persist to github or other git storage your changed configs
For github most proably you'll need to add you remote
cfg remote add origin [email protected]:<username>/dotfiles.git