Over the weekend I did something long overdue; cleaning up of my dotfiles. I've done things a stupid way in the past where I'd store my dotfiles in iCloud Drive as a duplicate of what was in my home directory.
Using git is a much better solution to this problem.
In interacting with ChatGPT it came up with a scripting strategy whereby you have this alias in your .zshrc
alias dot='/opt/homebrew/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
which creates an empty git directory named .dotfiles in your home and you interact with your dotfiles using dot instead of git.
So whenever I update my .zshrc now the flow is
dot status
dot add -u
dot commit -m "Commit message"
dot push
and everything is stored remotely in GitHub ready for a new machine whenever I switch.
I'm currently also storing my Ghostty config file as well as my .gitconfig. But the main thing I need to store somewhere safe is the .zshrc as I have a number of aliases and functions now that should be tracked.