Create the repository:
git init --bare $HOME/.dotfiles-git
Add an alias that separates interacting with the dotfiles repository:
git config --global alias.dotfiles '!git --git-dir=$HOME/.dotfiles-git/ --work-tree=$HOME'
When running git status
, only show files that have previously been tracked:
git dotfiles config status.showUntrackedFiles no
The repository can be used to track dotfiles in the same way as you would normally use git:
git dotfiles add .
git dotfiles commit -m "my commit"
git dotfiles push origin main
Make sure the alias has already been added:
git config --global alias.dotfiles '!git --git-dir=$HOME/.dotfiles-git/ --work-tree=$HOME'
To clone a bare repository, run:
git clone --bare <git-repo-url> $HOME/.dotfiles-git
Checkout the actual content from the dotfiles repository:
git dotfiles checkout