How to manage dotfiles in bare git repository This note was created on 2023-05-10 This note was last edited on 2023-06-26 === Start from scratch === 1. Initiate bare git repository in your $HOME: $ git init --bare ~/.dotfiles --initial-branch linux 2. Configure alias in your ".bashrc" or ".zshrc": ~~~ alias dotfiles="/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME" ~~~ 3. Hide files we are not explicitly tracking: $ dotfiles config --local status.showUntrackedFiles no 4. Check status of repository: $ dotfiles status 5. Configure remote repository: $ dotfiles remote add origin *git-repo-url* 6. Add files to repository, commit and push to remote: $ dotfiles add ~/.config/someapp1/settings.json $ dotfiles commit -m "Initial commit" $ dotfiles push origin linux === Load dotfiles on a new system === $ git clone --bare *git-repo-url* ~/.dotfiles --branch *branch-for-your-os* $ git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME checkout linux $ dotfiles config --local status.showUntrackedFiles no === Tips === Fetch other dotfiles/branch for different setup/OS: $ dotfiles fetch origin macos:macos Check difference between GNU/Linux and Apple macOS dotfiles: $ dotfiles diff macos linux Add files to current dotfiles from other dotfiles/branch: $ dotfiles checkout linux -- ~/.config/someapp2/settings.json