Like any configuration obsessed nerd I have a collection of “dot files”; configurations for the variety of tools, command line and otherwise, that I use. Initially having these stored in a Git repository was convenient for experimentation, but over time I have come to appreciate being able to quickly setup my preferred tools with my configuration on a new computer.
When the new computer is one of my own, having a single source for these configurations was fine. As soon as I started using these tools, and their configurations, on work computers, I started running into minor edge cases. Maybe I wanted a different font size for the desktop at work than on my personal laptop. Or, the user specified in the Git configuration needed to be different between work and home.
For a long time I tried having a branch called work to isolate changes that
were work specific. But this was tedious at times and so I stopped using it.
Finally I decided to have two sets of dot files. I created a new GitHub
account, expressly for work. And in that account I made a fork of my dot files
repository. Not only did this simplify the management of of my dot files, it
also allowed me to eliminate configurations from the work side that I only used
in my personal computing.
With the new repository I needed to update the git remote on the local repository. Running this command updates the remote:
git remote set-url origin git@github.com:<work-account>/dotfiles.git
Furthermore, I could add an upstream remote to the original repository:
git remote add upstream git@github.com:<personal-account>/dotfiles.git
Changing the original remote via the set-url command has some advantages:
Symlinks stay intact. The directory hasn’t moved, so ~/.config symlinks
continue to work
History preserved. All the local commits and branches remain.
No re-setup required. Everything stays in place.
Cleaner workflow. It is easy to sync between personal and work repositories if needed.
As a final step after updating the remote, do a git fetch to update
remote-tracking branches.