GitOps: Managing your dotfiles and source lists with Git and stow
Objectives
After reading this quick tutorial, you will be able to:
- Store, back up and recall configurations easily and reliably using Git
- Import said configurations into other computers and have them behave similarly
A background story of stow
According to the GNU project, Stow is a symlink farm manager. In other words, it tries to replicate the file structure stored in a particular folder by making symbolic links to all files and folders inside that folder but somewhere else in our system.
The directory structure in our repository must resemble that of our user home directory. If we wish to keep our vimrc file as well as other vim configuration files versioned in the same relative path as usual, we should then create a vim folder inside our dotfiles folder and run the stow command.
As an example, I've included a picture of my own home folder tree and how the symbolic links link back to the files I store in the dotfiles folder.
The beauty and joy of Git in configuration management
We can now harness the full potential of Git and the Git filesystem by creating a repository inside our dotfiles folder. Not only will we be able to back up our configuration files to a remote repository anywhere, but we also gain the ability to revert undesired changes made to those files by third-party applications and other rogue scripts running on our machines. No more sweating over changes, if your repository is kept up-to-date, that is.
There you have it: a little taste of that DevOps goodness in your everyday computing lives.
sudo stow -t [target] [origin]