Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

I do something similar, though for historical reasons I use CVS rather than Git.

I keep all my $HOME/.* files (and $HOME/bin/* scripts) in a CVS repository. I then manually use update-home and update-bin scripts that I've written to copy the files into $HOME or $HOME/bin, respectively. It's a little bit wasteful of space (I suppose I could use symlinks instead), but not badly so -- and by copying rather than symlinking, I can experiment with files in the repository without affecting my home directory.

The update-home command, among other things, makes backup copies of any files that already exist, so that I don't clobber the .bashrc file that was created when my account was set up. (And update-bin edits #! lines as needed, for example if I want to use a Perl executable other than /usr/bin/perl.)

(My update-home and update-bin scripts aren't designed to be usable by others; they're full of hardwired names that apply only to me. Just copying the files manually would work about as well.)

A common practice is to backup your dotfiles in github. There is a lot of work done for that practice.

The idea is to clone that repository for each new computer you want to use.

You can have a look to my personal repo to see how I implemented it. In my case I used a perl script called dfm to handle those symbolic links

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top