Sample Header Ad - 728x90

Opposite of `--adopt` option for GNU Stow?

8 votes
4 answers
5282 views
I'm using [GNU Stow](https://www.gnu.org/software/stow/) to manage my dotfiles as per [this guide](https://alexpearce.me/2016/02/managing-dotfiles-with-stow/) . This works well for cases where there is no pre-existing dotfile on the machine. E.g. if there is no file ~/.config/foo.cfg then the following works well: ~/.dotfiles$ mkdir -p foo/.config ~/.dotfiles$ echo My config > foo/.config/foo.cfg ~/.dotfiles$ stow foo ~/.dotfiles$ ls -l ~/.config lrwxrwxrwx 1 user group 21 Dec 6 19:03 ~/.config -> .dotfiles/foo/.config It becomes less straightforward if ~/.config/foo.cfg already exists: ~/.dotfiles$ stow foo WARNING! stowing bar would cause conflicts: * existing target is neither a link nor a directory: foo.cfg All operations aborted. So far the only solution I can find is to manually delete ~/.config/foo.cfg and re-run stow foo. This is quite awkward when provisioning a stow repo to a new machine which might have dozens of pre-existing .dotfiles and essentially defeats the purpose of using stow to manage dotfiles. Stow has the --adopt option. Running stow --adopt foo has the effect of replacing the stow'd foo files with the pre-existing foo files that are on the machine, and then creating the symlinks. What I'm looking for is the way to achieve the opposite; replace the machine's .dotfiles with a symlink to the stow'd version so that new machines can be provisioned using the stow'd dotfiles from a Git repo. This seems like such an obvious requirement for using Stow to manage dotfiles that I feel I'm missing something and/or the problem has been solved. Any ideas?
Asked by JBentley (253 rep)
Dec 6, 2021, 07:26 PM
Last activity: Mar 15, 2024, 07:06 AM