Backing up dotfiles with stow and git

Whether you've been a *nix user for a long time or are just starting out, you know that your configuration files are important to customizing your experience. You spend a lot of time setting up software 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 configurations in a new environment. We can accomplish both of these goals with stow and git.


Configuration files (called dotfiles because their names often begin with “.”) contain important information that tells your installed 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 .config and, if you're using OSX, some could end up under ~/Library/Application 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 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 additional 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 synchronized with the Dropbox cloud service and are accessible wherever 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 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.