You can also use yadm to manage dotfiles without writing aliases. These two methods are compatible (both based on Bare Git Repository).
git clone --bare https://github.com/waleslau/dotfiles.git $HOME/.local/share/dotfiles.GitBareRepo
alias cfgit='/usr/bin/git --git-dir=$HOME/.local/share/dotfiles.GitBareRepo --work-tree=$HOME'
# move all the offending files to $HOME/.local/share/dotfiles.backup
mkdir -p $HOME/.local/share/dotfiles.backup && cfgit checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} mv {} $HOME/.local/share/dotfiles.backup/{}
cfgit checkout
# There may be error messages, need to create some subdirectories manually, then execute the above script again to move the old configuration file, and then checkout again
then enjoy it.
git init --bare $HOME/.local/share/dotfiles.GitBareRepo
alias cfgit='/usr/bin/git --git-dir=$HOME/.local/share/dotfiles.GitBareRepo --work-tree=$HOME'
echo "alias cfgit='/usr/bin/git --git-dir=$HOME/.local/share/dotfiles.GitBareRepo --work-tree=$HOME'" >> $HOME/.bashrc
echo "alias cfgit='/usr/bin/git --git-dir=$HOME/.local/share/dotfiles.GitBareRepo --work-tree=$HOME'" >> $HOME/.zshrc
# ignore everything
*
# if want to tracking some file, must be added manually, like this:
# cfgit add -f filename
cfgit add -f .gitignore
cfgit commit -m "first commit"
Then it can be pushed to the remote repo
cfgit remote add xxx xxxxx.git
cfgit push -u xxx <branch>
enjoy it.