Skip to content

Instantly share code, notes, and snippets.

@gadzhimari
Last active February 24, 2018 18:25
Show Gist options
  • Save gadzhimari/f577ba34daac27c4a4e887af85d704bd to your computer and use it in GitHub Desktop.
Save gadzhimari/f577ba34daac27c4a4e887af85d704bd to your computer and use it in GitHub Desktop.
Dotfiles syncing through bare git repository

Note: No extra tooling, no symlinks, files are tracked on a version control system, you can use different branches for different computers, you can replicate you configuration easily on new installation.

git init --bare $HOME/.dotfiles
alias config='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
dotfiles config --local status.showUntrackedFiles no
  • The first line creates a folder ~/.dotfiles which is a Git bare repository that will track our files.
  • Then we create an alias config which we will use instead of the regular git when we want to interact with our configuration repository.
  • We set a flag - local to the repository - to hide files we are not explicitly tracking yet. This is so that when you type config status and other commands later, files you are not interested in tracking will not show up as untracked.
  • Also you can add the alias definition by hand to your .zshrc or use the the fourth line provided for convenience.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment