Search code examples
gitgithubgithub-apigit-remote

Github for the second user: how to set up


I've tried to setup a second user for github. I followed this article, created SSH key, tied it to my github.com accound and added remote origin.

How do I proceed from this moment on? When I use

git config user.name git config user.email

commands it still dispays the 1st account's data.


Solution

  • user.name/email have nothing to do with authentication. Only with commit authorship.

    Check if your second key is cirrectly recognized by GitHub:

    ssh -T github-COMPANY
    

    (with github-COMPANY the key in your ~/.ssh/config file, which references your second private key, provided your registered your second public key to your second GitHub account)

    If this works (you get a Welcome message), then in your second local repo, use that URL:

    git remote set-url origin github-COMPANY:<secondUser>/<secondRepo>
    

    And push.