Search code examples
git

Why use a bare repository for config dotfiles?


I have read this article, describing how to use git and configure dot files over many computers: https://www.atlassian.com/git/tutorials/dotfiles

The author uses a bare repository and changes the working directory to $HOME for the dot files. Why does the author use a bare repository in this context? Could you just not take a normal repository and set the WORK_DIR to the $HOME directory?


Solution

  • You can indeed do that.

    It's not clear to me why the author chose to do that, but in general, making your home directory a Git repository means you have to ignore almost all files by default and either add exceptions or add new files with git add -f, or else every file anywhere under your home directory will be considered an untracked file in your repository. Using a bare repo with a special alias means that by default, your home directory won't be considered a repository, avoiding all those problems.

    Another option that you can use is to use a normal repository located elsewhere and have a script or Makefile to copy the files into place.