I need an elegant solution to store my dotfiles on GitHub for easy access. I tried to create a dotfiles directory and symlink all the dotfiles into there. Then I tried adding the symlinks to git and committing in that directory, but git saves the links not the contents of the files it points to. Is there a way to do this or something similar?


I have no idea what the best approach is and elegance is certainly in the eye of the beholder, but I use the following for my dotfiles:

  • A ~/.dotfiles directory that contains all of the dotfiles themselves. These are all managed in a git repo.
  • A script, also in ~/.dotfiles that creates the required links into my home directory. I don't have any dotfiles in my home directory, only links into ~/.dotfiles. For example:

    $ ls -l ~/.muttrc
    lrwxr-xr-x  1 mj  mj  25 May  4  2014 /home/mj/.muttrc -> /home/mj/.dotfiles/muttrc

After I've cloned the repo onto a new machine (into ~/.dotfiles), I just run the script to update the symlinks.

I've found the above approach works very well for me.

  • This works for me for more basic files but when I try to symlink something like my .oh-my-zsh/custom directory, zsh does not follow the symlink and says my theme cannot be found – carloabelli Jul 29 '15 at 10:40
  • I don't use oh-my-zsh but I'm guessing that you may need to symlink the files below ~/.oh-my-zsh and not the directory itself. My dotfiles setup is fairly complex (with subrepos below it for various vim addons, etc) and I've not run into any issues with it. – mjturner Jul 29 '15 at 10:52
  • Yeah just a pain to have to create and symlink every file I create rather than have all files in directory automatically symlinked but I can deal with it – carloabelli Jul 29 '15 at 10:57
  • 1
    @cabellicar123, see also: dotfiles.github.io – Evgeny Vereshchagin Jul 29 '15 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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