2 GitHub accounts on the same computer? Do how
Like a company account, a personal account.
Private accounts are as follows:
email [email protected]
Account Number: Example
The company's working account is as follows:
[Email protected]
Account Number: MyWork
CD to the ~/.SSH directory and use Ssh-keygen to generate a different SSH key. The command is as follows:
CD ~/.sshssh-keygen-t rsa-c "[Email protected]"
When prompted to enter the file name of SSH key, write the name you want. My work account used the original ID_RSA, personal account using Id_rsa_personal.
Modify the SSH config file (~/.ssh/config), and if not, create a new one. The contents are as follows:
# personal account
host github_me.comhostname github.comUser expampleIdentityFile ~/.ssh/id_rsa_personal
# work accountHost github.comHostname github.comUser myworkIdentityFile ~/.ssh/id_rsa
In this case, a few notes are needed
1.remote Pull push when there is a problem, because to set the mailbox problem pull when the identification of the mailbox, 2 GitHub account, 2 mailboxes, we naturally can not use the global User.email
1).取消globalgit config --global --unset user.namegit config --global --unset user.email2).设置每个项目repo的自己的user.emailgit config user.email "[email protected]"git config user.name "suzie"
Then push pull has a problem with the wood. Since there is no global config, you will be prompted to set the user email and name for the project when you use Sourcetree.
2. If the above steps still do not work, please use the following command line SSH key to the SSH agent
Ssh-add ~/.ssh/id_rsa_work
3. You can test the SSH-T host for detection to see if it was added successfully. Such as:
Ssh-t github_me.com
GitHub Multi-account usage