Tweaking GitHub to improve my work-life balance

GitHub is a wonderful development resource that is now widely used within the iOS community. I use it to host my personal projects and increasingly the clients that I work with also use it. For a number of years, I used the one account across both personal and client projects by adding an additional SSH key for each new computer to that account. GitHub does a good job of separating how multiple organisations are handled on the same account by allowing custom notification routing rules per organisation (e.g. work notifications go to your work email address and personal notifications to your personal one) however I wasn't able to find a way to separate by organisation content on the Browse activity tab on the homepage. I often use the Browse activity tab to see the people I follow as a way to discover interesting projects. Now I jealousy guard my personal time and having a combined Browse activity tab meant that on my evenings and weekends I would accidentally see that Jack from work had created a new PR or Susan had left some comments on mine - seeing this prevented me from truly clocking-off and left me feeling uneasy, like I should have been reviewing that PR or responding to those comments. On the few occasions that I gave into this unease, I then felt guilty about doing so like I was cheating myself somehow 😤. So it seemed that even just knowing that things had moved on since I left the office left me with an unease that I wasn't able to shake no matter what I attempted to do. I needed a way to truly disconnect my personal and professional programming while still using GitHub for both - I needed a way to improve my work-life balance.

work-life-balance-stones-1

The only way that I could think to achieve this disconnect was by creating multiple GitHub accounts and so free my Browse activity tab from unwanted (in that moment) notifications. Now, creating and using multiple GitHub accounts on the same computer proved to be slightly trickier than I thought it would be.

Adding multiple GitHub accounts to the same computer

After creating the needed additional GitHub accounts, I then needed to generate new SSH keys for each account. Thankfully this is not a new issue and is only slightly different from the standard GitHub flow. A number of articles on how to do this have already been written, so I won't go into it here but I found this one to be particularly useful. After following that article and a few other tweaks, I had a config (~/.ssh/config) file that looked like:

Host personal
  HostName github.com
  User git
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_rsa_personal

Host work
  HostName github.com
  User git
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_rsa

However after a restart of my computer I noticed that I would sometimes get a permissions error when attempting to push changes to my personal repos as git was using my work account as the primary account. This was despite specifying which account to use when cloning by:

git clone personal:wibosco/CoreDataServices.git

or

git clone git@personal:wibosco/CoreDataServices.git

I eventually noticed that it worked if after each restart I ran:

ssh-add -K ~/.ssh/id_rsa_personal

(id_rsa_personal is the name of the IdentityFile as specified in the above config)

This felt odd and I wondered why the articles I read on setting up multiple accounts didn't mention this annoying trade off. Further googling eventually led to me to this stackoverflow question. The issue was related to how the SSH agent worked on OS X - even though the identity to use was specified when cloning, the agent was offering all the loaded keys it had to authenticate when cloning that repo. It just so happened that my work key was offered and accepted first (this would also explain why running ssh-add -K ~/.ssh/id_rsa_personal after a restart gave me access to that repo - it must have pushed that key to be the first one offered by the agent). The solution (as the accepted answer details) is to force the key that you detailed in the clone to be used by adding IdentitiesOnly yes to the config:

Host personal
  HostName github.com
  User git
  AddKeysToAgent yes
  UseKeychain yes
  IdentitiesOnly yes
  IdentityFile ~/.ssh/id_rsa_personal

Host work
  HostName github.com
  User git
  AddKeysToAgent yes
  UseKeychain yes
  IdentitiesOnly yes
  IdentityFile ~/.ssh/id_rsa

With that change I was now able to switch between my various accounts without issues 🎉.

But more importantly I was able to improve my work-life balance by removing that general sense of unease I would sometimes get by being able to avoid any work-related notifications during my personal time. I don't have any data on how this change impacted by productivity but I imagine that this made me more productive in both my professional and personal programming activities.

What do you think? Let me know by getting in touch on Twitter - @wibosco