I'd like to put all my dotfiles (like .profile, .gitconfig, etc.) in a central git repository, so I can more easily keep track of the changes. I did this, but I would like to know how to properly handle keeping them in sync with the actual ones in ~/. I thought that you could just hard link the two using ln, but this does not seem to work as I expected, i.e., if I edit one file, the other does not change. Maybe I misused the ln command, or else I misunderstand how hard links work.

How do people usually do this? Judging by GitHub, it's a pretty popular thing to do, so surely there's a seamless way to do it that someone has come up with.

By the way, I'm on Mac OS X 10.6.

link|improve this question
feedback

2 Answers

up vote 3 down vote accepted

Many OS X programs, such as TextEdit, save files in a way that breaks hard links.

At least on Linux, symlinks are usually used for this purpose:

$ ln -s ~/dotfiles/bashrc ~/.bashrc
link|improve this answer
OK. I've been using TextWrangler to edit the files, so maybe it is screwing them up. I'll try symlinks and see if they work. – asmeurer Jun 28 '11 at 3:33
I tried symlinking my .profile file, but source ~/.profile gave -bash: /Users/aaronmeurer/.profile: Too many levels of symbolic links. – asmeurer Jun 28 '11 at 3:45
@asmeurer: You symlinked it to itself. (Remember that link targets are relative to the link itself, not to your current directory.) – grawity Jun 28 '11 at 9:10
I see. It's essential to give absolute paths as arguments to ln. It works when I do that. – asmeurer Jul 10 '11 at 2:31
@asmeurer: Not necessarily. ln -s dotfiles/bashrc ~/.bashrc would work as well, as long as you remember that it's relative to ~/. – grawity Jul 10 '11 at 9:29
feedback

There is a rubygem: homesick which solves all of this! it supports github out of the box and will symlink everything for you.

protip: if you add changes to the dotfiles you'll still need to clone the repos in a seperate dir, make changes from and there push. then pull them with homesick.

additional if you're using VIM?:

use pathogen because it works really well when managing dotfiles in git. Plugins can be added as submodules and will load effortless.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.