GitHub Error: Key already in use

后端 未结 7 1951
逝去的感伤
逝去的感伤 2021-01-30 02:54

I have created two GitHub accounts. One for my work user and one for my personal self. I needed to do catch up on some work and as such cloned my work repo onto my personal PC

7条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-30 03:50

    You can create one more key pair, say id_rsa_personal.pub, and add it to the Github account.

    Next, create/edit the .ssh/config file.

    # Default GitHub
    Host github.com
      HostName github.com
      User git
      IdentityFile ~/.ssh/id_rsa
    
    Host github-public
      HostName github.com
      User git
      IdentityFile ~/.ssh/id_rsa_public
    
    Host github-personal
      HostName github.com
      User git
      IdentityFile ~/.ssh/id_rsa_personal
    

    The above file will help you to use more than one Github account. For background info, refer to the answers to this question.

    Next, you will need to alter your .git/config remote url to point to:

    git@github-personal:/.git

    Rather than the usual:

    git@github.com:/.git

提交回复
热议问题