- Create a git bare repository with the following line
mkdir $HOME/.dotfiles
git init --bare $HOME/.dotfiles
- Create an alias for a better managing of the configuration
alias cfg='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
It should be highlighted that you can put it in your .bashrc or the file you use for your alias, in my case $HOME/.zshrc
- Disable the tacking of any single file
cfg config --local status.showUntrackedFiles no
- You can use it in a normal basis with config and keywords like "add, delete, status, checkout, ...". Remember to add a remote repositoryy with this lines
cfg remote add origin <remote-url>
cfg push -u origin main
For example you can create a diferent configuration in different branches for each machine that you have.
- Prevent weird circular dependencies
echo ".dotfiles" >> .gitignore
- Clone the remote repository
git clone --bare <remote-git-repo-url> $HOME/.dotfiles
- Restore the alias and configuration of tracking
alias cfg='/usr/bin/git --git-dir=$HOME/.dotfiles --work-tree=$HOME'
cfg config --local status.showUntrackedFiles no
- Proceed to checkout
config checkout