Git uses two github accounts on a single computer

Source: Internet
Author: User

Demand:

The company has GitHub account, own GitHub account, want to use on git simultaneously, the two do not interfere.

Ideas:

Management of two Shh key.

Solution:

First, generate two SSH keys

For example, the "one"and "two"two accounts are used here. Same below

Ssh-keygen " [email protected] "  ssh-keygen"[email protected]"

Don't go all the way back in the first conversation by typing the rename (id_rsa_one and id_rsa_two), which generates two copies of 4 files containing the private key and the public key.

Note 1:ssh-keygen is a Linux command that lets you use SSH between two machines without requiring a username and password

Stay 2: Be sure to run the command line under the ~/.SSH path, otherwise the resulting file will not appear in the current directory

Second, add the private key

1. Open ssh-agent


(1) If you are the official GitHub bash:

ssh-agent -S

(2) If you are other, such as Msysgit:

$ eval $ (ssh-agent -s)

2. Add private key

ssh-add ~/. ssh/ssh-add ~/. ssh/id_rsa_two

Third, create config file

Touch Config

The empty config file appears, and then add the following:

# One ([email protected])    one.github.com  ~/. ssh/id_rsa_one User One # ([email protected] gmail.com)    two.github.com~/.  SSH/id_rsa_two User

Iv. Deployment of SSH key

Login to two GitHub accounts and enter Personal settings –> SSH and GPG keys:

Click "New SSH Key" to add the contents of the following two public keys to the respective GitHub account.

V. Remote testing "can skip"

SSH ssh –T two.github.com

Vi. Use of

1. Clone to Local

(1) The original wording:

$ git clone [email protected]: One's user name/learngit.git

(2) The current wording:

$ git clone [email protected]one.github.com: one username/learngit.git$ git clone [email protected]  two.github.com: User name of two /learngit.git

2, remember to this warehouse set local user name and mailbox:

" One_name " " One_email "  "two_name" "two_email "

3, the above are successful, you will find that the key will be changed from gray to green.

Git uses two github accounts on a single computer

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.