'Stow and replace existing dotfiles

I'm using most recommended method of managing dotfiles on mac by using stow. e.g., https://alexpearce.me/2016/02/managing-dotfiles-with-stow/

I found that it works great and does what I need to if I'm doing a clean install. I have a folder structure that looks like this inside my ~/dotfiles folder

.
├── install.sh
└── zsh
    └── .zshrc

when I run

stow zsh

It correctly sets the symlink in place from ~/.zshrc

.zshrc -> dotfiles/zsh/.zshrc

Problem however is if .zshrc is already present in the home folder, then stow will not override it with symlink. Instead it will just throw and error.

WARNING! stowing zsh would cause conflicts:
  * existing target is neither a link nor a directory: .zshrc
All operations aborted.

I understand I can manually "rm ~/.zshrc" file before running stow and will work.

I'm trying to see if there is cleaner way of setting up symlinks without having to manually run rm command for all the existing dotfiles.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source