Ilias95 Ilias95 - 26 days ago 8
Git Question

How to treat a local dotfile repository?

As many others, I want to have a git repository with my configuration files and also upload a backup of it to a hosting site. My question is how to treat the dotfiles of the local repo.

Let's say that I have my zshrc/bashrc in the dotfiles repo.
I can put the line 'source /path/to/local/repo/zshrc' to my ~/.zshrc file and everything's fine. Same thing with vimrc.

But what about those dotfiles that doesn't support such a command? Should I have the same content in both ~/.conffile and /pathtolocalrepo/conffile and when I make a change to one of them update the other file? Or is there a smarter way?

What's the common practice?

Also where this local repository is located usually (on Linux)?
I don't think home folder is the right place to put it (config files should be available to other users too), but which place suits it best?

Thanks in advance.

Answer

You should probably use symbolic links.

ln -s /path/to/repo/.zshrc ~/.zshrc

That means that when you try to access ~/.zshrc, this will instead look for the file /path/to/repo/.zshrc

For more infos on symbolic links, check this out : Symbolic Links

Note that you can perfectly create a "hard" link (without the -s option), only difference is that with hard links you cannot link directories nor link through filesystems (if /home and /path/to/repo are not on the same disk / partition)

Also where this local repository is located usually (on Linux)? I don't think home folder is the right place to put it (config files should be available to other users too), but which place suits it best?

I usually place all my git repositories in the ~/git folder but this really is a personal choice.