Using git with alternative username

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
User git
IdentityFile /home/hanna/.ssh/sztrovacsek/id_rsa
IdentitiesOnly yes

$git remote add privorigin github-sztrovacsek:sztrovacsek/django.git

$ git remote -v
origin (fetch)
origin (push)
privorigin github-sztrovacsek:sztrovacsek/django.git (fetch)
privorigin github-sztrovacsek:sztrovacsek/django.git (push)
upstream (fetch)
upstream (push)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>