Commit ed1734fa05

ed1734fa0545d23737a4a4db9e2fbd097fd8dd6f

parent: cc9fded341

Unsigned

cmc <hello@cleberg.net> · 2026-02-08 18:57 UTC

publish post: gnu-stow

Layout: unified · split

content/blog/2026-02-08-gnu-stow.org added +101
@@ -0,0 +1,101 @@
1#+date: <2026-02-08 Sun 12:17:42>
2#+title: Managing My Dotfiles with GNU Stow and Git
3#+description: Learn how I use GNU Stow to manage my user dotfiles and configurations.
4#+slug: gnu-stow
5
6* What is GNU Stow?
7
8[[https://www.gnu.org/software/stow/][GNU Stow]] is described as a "symlink farm manager" on its homepage, which is
9true, but feels a bit underwhelming. Rather, I'd describe it as a tool to
10systematically and logically link, organize, and version control any files on
11your system.
12
13* Installation
14
15First things first: let's install Stow. I'm on macOS, so I run the following
16command:
17
18#+begin_src sh
19brew install stow
20#+end_src
21
22To ensure it's installed correctly, check the version:
23
24#+begin_src sh
25stow -V
26#+end_src
27
28* Stow Dotfiles
29
30Next, let's create a directory to use as the central source for all these files.
31In my case, I store all git repositories in my ~~/git/~ directory, so I will
32create a ~dotfiles~ directory here:
33
34#+begin_src sh
35# Create the dotfiles repository
36mkdir ~/git/dotfiles && cd ~/git/dotfiles
37#+end_src
38
39Next, let's stow our first set of dotfiles. We'll use ~zsh~ as an example here. To
40do this, we will:
411. Create a directory for Zsh.
422. Move our current Zsh configuration files into our Stow directory.
433. Use Stow to symlink the files back into our home directory.
44
45#+begin_src sh
46# Create the ZSH Stow directory
47mkdir zsh && \
48# Move your ZSH files into Stow
49mv ~/.zshrc ~/git/dotfiles/zsh/ && \
50mv ~/.zprofile ~/git/dotfiles/zsh/ && \
51# Use Stow to symlink them back to your user home
52stow zsh
53#+end_src
54
55At this point, you have a centralized directory (~/git/dotfiles~) where you can
56stow any file and use ~stow~ to symlink it back to another directory on your
57system.
58
59Therefore, you only need to navigate to this directory to make changes across
60your system.
61
62* Update Dotfiles
63
64When you make changes to your Stow directory, you can inform Stow and have the
65program update its symlinks with the following command:
66
67#+begin_src sh
68cd ~/git/dotfiles && \
69stow -R zsh
70#+end_src
71
72To summarize:
73
74| Action | Command | Why? |
75|---------------------------------+-------------------+--------------------------------------------------|
76| Edited a file | None (Just save) | The symlink already exists. |
77| Added a file to existing folder | stow -R <package> | To create the new symlink for that file. |
78| Deleted a file from dotfiles | stow -R <package> | To remove the "dead" symlink from your home dir. |
79| Created a whole new package | stow <package> | To link the new directory for the first time. |
80
81* Save to a Git Repository
82
83Lastly, let's finish the puzzle by ensuring that this configuration is
84long-lasting and can transfer amongst systems.
85
86To this end, we will use Git as our VCS. You can simply create the repository,
87add your files, and push to your remote.
88
89#+begin_src sh
90git init && \
91git add . && \
92git commit -m "initial commit" && \
93git remote add origin GIT_URL && \
94git push
95#+end_src
96
97If you want to automate this even more, write an alias or a hook into your ~stow~
98command to automatically commit your changes whenever they occur.
99
100At this point, I have organized and managed my dotfiles much more efficiently
101and no longer lose them whenever I wipe my machines.