From: [email protected]
Date: 2017-03-24
Subject: Backing up dotfiles with stow and git

Whether  you've been a ix user for a long time or are just starting
out, you know that your configuration files are important  to  cus-
tomizing  your experience. You spend a lot of time setting up soft-
ware and tweaking your configuration files, so it  makes  sense  to
keep them organized and back them up in case something bad happens.
It would also be nice to be able to quickly deploy these configura-
tions  in  a new environment. We can accomplish both of these goals
with stow and git.

Dotfiles

Configuration files (called dotfiles because their names often  be-
gin  with  ".")  contain  important information that tells your in-
stalled programs how you want them to run. Some of these files  get
groomed  and perfected over time as their users make adjustments to
their workflows. Keeping track of them  can  be  difficult  because
there is no standard repository for these files.  Some of them wind
up in your home directory, some are stored under ~/Library/Applica-
tion Support. Some config files even get their own folder.

GNU stow

GNU  stow allows you to organize all of your dotfiles into a single
folder tree. Stow will create symbolic links to these files in  all
the  right  places.  Using  GNU  stow to manage your dotfiles[1] by
Brandon Invergo does an excellent job of explaining how to use stow
for  this  purpose.  It can be a little nerve-wracking to move your
configuration files around. If  it's  practical,  consider  tarring
your  home  directory  so  that  you can restore it in the unlikely
event that things go awry.

On OSX, I had to install GNU stow using brew:

 `$brew install stow`

I also found that reading the manpage for stow provided some  addi-
tional insight into using stow for this and other purposes.

git and Dropbox

Now  that  all  of your configuration files are consolidated into a
single folder, you can use git to track changes over time and  also
to  back  your  files up to a remote location. In this example, I'm
using Dropbox, but this is transparent to git. As  far  as  git  is
concerned,  I'm pushing to a repository on my local disk. The magic
of Dropbox, of course, is that the contents of this folder are syn-
chronized with the Dropbox cloud service and are accessible wherev-
er I can access Dropbox. (Even if you are using a machine without a
Dropbox client, you can use a public link to access your repository
over http.)

This will walk you through the process[2]  of  initializing  a  git
repository.  Not  only does this effectively back up your dotfiles,
but you can track changes over time and restore to a previous state
in the event of a misconfiguration.

[1]: http://brandon.invergo.net/news/2012-05-26-using-gnu-stow-to-manage-your-dotfiles.html
[2]: http://stackoverflow.com/questions/1960799/using-git-and-dropbox-together-effectively