Skip to content

Instantly share code, notes, and snippets.

@amitiuttarwar
Created November 25, 2019 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save amitiuttarwar/facd78fd262a6c33eef6a97368cd33b1 to your computer and use it in GitHub Desktop.
Save amitiuttarwar/facd78fd262a6c33eef6a97368cd33b1 to your computer and use it in GitHub Desktop.
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.

Setup

  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 git@github.com:amitiuttarwar/amus_dotfiles.git

Ongoing

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

source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment