Create a "bare" git repository:
git init --bare .dotfiles
--bare flag creates a repository that doesn’t have a working directory, making it impossible to edit files and commit changes in that repository.
Create an alias to manage the repository we just created:
alias dotfiles="/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME"
Ignore the files that are not being tracked from being shown up in
dotfiles config --local status.showUntrackedFiles no
Add your desired files:
dotfiles add .bash_aliases
dotfiles commit -m 'Add .bash_aliases'
Now with the use of a
bare repository, there is no
.git directory in your
$HOME directory; so it does not introduce any surprises while working with
That's how I manage my
dotfiles. I first read about it here years ago.