I have a regular git username which I use with key based authentication, and it’s set up the most standard way, following the excellent tutorial for it from github. I use this username for work.
I also have another git username which I use for my private stuff.
Whenever I need to commit to a repository where I want to commit with my alternative username, I need to do this magic.
$echo ~/.ssh/config
Host github-sztrovacsek
HostName github.com
User git
IdentityFile /home/hanna/.ssh/sztrovacsek/id_rsa
IdentitiesOnly yes
$git remote add privorigin github-sztrovacsek:sztrovacsek/django.git
$ git remote -v
origin git@github.com:sztrovacsek/django.git (fetch)
origin git@github.com:sztrovacsek/django.git (push)
privorigin github-sztrovacsek:sztrovacsek/django.git (fetch)
privorigin github-sztrovacsek:sztrovacsek/django.git (push)
upstream git@github.com:django/django.git (fetch)
upstream git@github.com:django/django.git (push)