Based on a Hacker News solution proposed by StreakyCobra
git init
a bare repository.
git init --bare $HOME/.dotfiles
Configure an alias to set the git directory and working tree in .zshrc or .bashrc.
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
Hide untracked files from git when calling dotfiles status
.
dotfiles config status.showUntrackedFiles no
Call any git command with the configured alias.
dotfiles add <file>
dotfiles status
dotfiles commit
dotfiles remote add origin <remote>
dotfiles push origin main
Clone the remote repository.
mkdir .dotfiles
git clone --bare https://github.com/USERNAME/dotfiles.git $HOME/.dotfiles
Configure an alias to set the git directory and working tree in .zshrc or .bashrc.
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
Hide untracked files from git when calling dotfiles status
.
dotfiles config status.showUntrackedFiles no
Checkout.
dotfiles checkout
$HOME
directory, checkout
will throw an error. You can either (1) delete them or (2) back them up somewhere else.dotfiles submodule update --init
regardless of whether you included the --recurse-submodules
option when cloning.