GitHub Multi-account usage

Source: Internet
Author: User
Tags ssh config ssh config file

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.