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?
Elegant Way To Store Dotfiles on GitHub
dot-filesgitgithubhomesymlink
Best Answer
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:
~/.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: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.