Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Managing dotfiles with work-trees.

Idea: make $HOME the git work-tree, with a bare repo in a dummy folder (.dotfiles). The git commands use .dotfiles as the git directory, and $HOME as the work directory.


  1. create "bare" repository
  • don't contain working tree aka copy of source files
  • store git revision history in root folder of repo instead of .git subfolder
mkdir $HOME/.dotfiles 
git init --bare $HOME/.dotfiles
  1. setup alias to run git commands in this repo (in .zshrc)
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
  1. add remote
dotfiles config --local status.showUntrackedFiles no 
dotfiles remote add origin


  • use dotfiles instead of git command whenever working with this repo.
  • can arbitrarily add files to push.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.