Multiple github accounts on the same computer?

后端 未结 25 2720
野的像风
野的像风 2020-11-22 02:56

Trying to work on my both my actual \"work\" repos, and my personal repos on git hub, from my computer.

The work account was set up first, and everything works flawl

25条回答
  •  猫巷女王i
    2020-11-22 03:31

    Option 0: you dont want to mess around with OS settings.. you just want to commit to a different github account with a different public key for one repo.

    solution:

    1. create the new key: ssh-keygen -t rsa -b 4096 -f ~/.ssh/alt_rsa

    2. add the key to the keyset: ssh-add -K ~/.ssh/alt_rsa

    3. copy and add the pub key to the github account: (see github instructions)

    4. test the key with github: ssh -i ~/.ssh/alt_rsa T git@github.com

    5. clone the repo using the git protocol (not HTTP): git clone git@github:myaccount...

    6. in the cloned repo:

      git config core.sshCommand "ssh -i ~/.ssh/alt_rsa -F /dev/null"
      git config user.name [myaccount]
      git config user.email [myaccount email]

    7. now you should be able to git push correctly without interferring with your everyday git account

提交回复
热议问题