I have been managing my dotfiles using the alias below.
alias dot="git --git-dir=$HOME/.dotfiles.git --work-tree=$HOME"
Credits to StreakyCobra
To avoid committing your whole
$HOME directory to git, use a .gitignore file:
# Ignore all files /* # but keep .ssh !.ssh # ignore everything under .ssh, to avoid committing rsa keys, known hosts, etc .ssh/* # but keep your config under vcs !.ssh/config