I've recently setup some of my various config files to be source-controlled in a Github repository. Here are some examples of what I mean by config files...
I've found a ton of benefits to doing this, which I'll try and detail in this post...
In the past when I've done things like customise my terminal - I would have no idea how to get it back exactly as it was if I lost all my settings. Even with my .gitconfig setup - there are aliases in there which I've fine-tuned over time, which I really wouldn't like to lose! And Vim... ha! Any Vim user who loses their config - good luck recreating that if you've been tweaking over time! Having all of these things in Github backed up takes a massive weight off my mind.
Every time I tweak a configuration - I create an explicit commit for that change with a meaningful commit message. No changes are accidentally made, and I'm free to play with my configuration temporarily. I can see those changes in my pending changes, and choose whether to revert or make them official with a commit.
Because this is a Github repository that contains all of my config files - it's now become quite important to me. They're not just random individual config files on my computer any more. Because of the above two points (confidence and intentional changes) - I've found that I'm now much more motivated to improve them and make more tweaks and customisations, to get an even more awesome setup!
Another obvious advantage is that I can share them between multiple machines. I have a desktop, laptop, and multiple VMs. If I make a tweak on one machine - I'll push those changes, and periodically pull when I'm on the another machines.
Because this is a Github repo, I can create issues against it. Quite often I'll be in the middle of something, and have an idea for a config tweak I'd like to do to improve my workflow - but I don't have time to do it at that moment. Eg. I mentioned earlier that I'd like to add VSCode and Rider config to it. Or it might be Vim tweak that I'll need to look up how to do. Github issues are perfect for capturing those ideas, so I don't forget!
Obviously each application has its config files in different locations - whereas a Git repo is just in one place. Symlinks solve this problem nicely! I have a Powershell script called
Setup.ps1 in the same repository, which ensures my symlinks are all setup (code is below). The script is idempotent, so I can run it anytime I want to make sure my system is up to date with any symlink changes I might have made on another of my machines.
Then I have folders for each app...
To pre-empt the obvious question of whether my repo is public - I'm afraid, it's not. I don't want to have to worry about what I push to it. Mostly, there's nothing sensitive in there - but there are a few directory aliases that point to client folders which include their project names. It's just easier to keep it private.
However, here's a Gist with my Setup.ps1 in it to get you started...
The above script and the folder structure in the screenshot above, should give you a good starting point and idea of how it works, for your own config files.
After I started doing this - I was talking about it with someone, and they asked if I was using 'dotfiles'. I had heard the term, but wasn't sure what it was. So I Googled it, and found this and a few blog posts. The name comes from the fact that quite a few config files start with a dot - eg.
.vimrc, etc. Whilst there seems to be a community around creating helper scripts around 'dotfiles' - from what I gather - it looks like this isn't an actual thing - but rather just a term for what I was already doing anyway. Ie. Leveraging symlinks to make config files source-controllable.