Manage and Git Backup Dotfiles with ‘stow’



Having allot of CLI tools and *nix style applications leaves behind dot files, or hidden files, usually in your home directory. ~/.ssh for your ssh client config or ~/.vimrc for vim client config for example.

Even if these files and folders are hidden, they still clutter up your home directory. Having them stored on one place helps keeping them organized. Or as stow puts it: Organize software neatly under a single directory tree.


If you are running macOS, stow is available via Homebrew

brew install stow

If you are running any other *nix OS, it should be available in your OS package manager.


To get started, create a dotfiles directory in your home directory

mkdir ~/dotfiles

Move a dotfile or dotdirectory to your newly created dotfiles directory (… wow). .vimrc for example

mv .vimrc ~/dotfiles

Hop into the dotfiles directory and apply stow

cd ~/dotfiles
stow .

Once applied, you should see the softlink in your home directory

cd ~
ls -la
.vimrc -> dotfiles/.vimrc

Versioning and Backing Up with Git

Now that your dotfiles/directories are neatly under a single directory tree, they can be managed with Git.

cd ~/dotfiles
git init
git add -A
git commit -m "Initial commit"

Add a remote and push your newly committed files

git remote add origin <remote-url>
git push

Please note that if your dotfiles/directory managed by stow and git contain secrets. DO NOT let them leave that directory, add them to .gitignore

echo '.dotfilewithsecret' > .gitignore

Organize them files.

Leave a Reply

Your email address will not be published. Required fields are marked *