David
David

Reputation: 3046

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?

Upvotes: 1

Views: 912

Answers (3)

David J RPI
David J RPI

Reputation: 21

A few other alternatives I like are:

Upvotes: 2

Good Pen
Good Pen

Reputation: 809

Using bare repo like that, can aovid caring lots of unknow files under your $HOME

I prefer this:

mkdir ~/dotF
cd ~/dotF
git init

then put files I know in the stand alone folder, and set some soft-links.
Just like a U-disk

Upvotes: 1

bk2204
bk2204

Reputation: 76774

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.

Upvotes: 4

Related Questions