DEV Community


Posted on

Organize your Dotfiles - with GNU Stow and Git


If you didn't know, "dotfiles" are those little files hidden in your system that make everything run just the way you like. They're those little configuration files that make your setup feel just right. But managing them can be a headache.

GNU Stow

Thankfully, there's a magical tool: GNU Stow. It's a powerful symlink farm manager, don't worry if it sounds like something out of a tech wizard's spellbook. Basically, it helps you organize your dotfiles without cluttering up your system. Think of it as your personal butler for keeping things tidy in your digital home.


Now, let's talk about Git. If you're a developer and haven't heard of Git, well, you might be living under a rock. It is like that friend who always remembers everything you've ever said or done, but in a good way. It tracks changes to your files over time, making it a perfect companion for version control.

Getting Started

Alright, enough talk about the tools, let's dive into action!


Just fire up your terminal and use your favorite package manager to install these tools.

I use Arch BTW, so I'll install them using pacman:

$ sudo pacman -S git stow
Enter fullscreen mode Exit fullscreen mode

For those on Debian-based systems like Ubuntu, it should be:

$ sudo apt install git stow
Enter fullscreen mode Exit fullscreen mode

Setting up your Dotfiles

Now that we've got the tools ready, let's organize our dotfiles into a directory. You can keep them wherever you want, but I like to have a dedicated folder in my home directory:

$ mkdir ~/.dotfiles
Enter fullscreen mode Exit fullscreen mode

Next, start moving your dotfiles into this directory. For example, if you want to manage your .bashrc, .vimrc, and .gitconfig, you'd do something like this:

$ mv ~/.bashrc ~/.dotfiles
$ mv ~/.vimrc ~/.dotfiles
$ mv ~/.gitconfig ~/.dotfiles
Enter fullscreen mode Exit fullscreen mode

Now, this is where the magic happens. We'll use GNU Stow to manage these dotfiles. Navigate to your dotfiles directory and use Stow to symlink them back to your home directory:

$ cd ~/.dotfiles
$ stow .
Enter fullscreen mode Exit fullscreen mode

While there are various ways to utilize Stow for this purpose, I'll share the method I find most straightforward: stow . (Yep, just a dot).

This might seem simple, almost too simple. This command tells Stow to symlink all the files and directories in the current directory (~/.dotfiles) back to your home directory, neatly organizing them as if they were originally there.

There are indeed other ways to manage your dotfiles with Stow, I stick to the trusty stow . method for its simplicity, flexibility, and cleanliness.

If you're curious and want to learn more about GNU Stow, the manual page is a treasure trove of information:

$ man stow

Version Control with Git

Now let's make sure we're keeping track of changes to our dotfiles using Git. Navigate to your dotfiles directory and initialize a Git repository:

$ cd ~/.dotfiles
$ git init
Enter fullscreen mode Exit fullscreen mode

Now that Git is watching over our dotfiles like a diligent guardian, let's make our first commit:

$ git add .
$ git commit -m "Initial commit"
Enter fullscreen mode Exit fullscreen mode

Now that we've got Git on board, you can optionally publish your dotfiles repository to platforms like GitHub, GitLab, or Bitbucket. This not only serves as a backup but also allows for synchronization across multiple devices.


You can find my personal dotfiles repo here:

Alright, so now you've got your dotfiles organized like a boss and Git keeping an eye on them. Managing your dotfiles doesn't have to be a headache anymore.

But remember, this is just the beginning of your dotfiles journey. There are countless ways to further enhance and customize your setup.

Top comments (0)