Use multiple git accounts on a single computer

Source: Internet
Author: User
Tags using git

Recently started using Git, and a new GitHub account was created today, the submission is always said that the first account does not have permissions, and then found that git push needs to differentiate the GitHub account, is now recorded solution:

1. Create SSH KEY$ ssh-keygen -t rsa -C "[email protected]",根据提示输入文件名,如id_rsa_two,粘贴复制到github的SSH

2. See if the config file exists under user ~/.ssh, if it does not exist using the command Touch Config, then configure config

#github Server One
Host GitHub
Hostname github.com
User git
Identityfile ~/.ssh/id_rsa
#github Server
Host Github_two
Hostname github.com
User git
Identityfile ~/.ssh/id_rsa_two

3. Test configuration, the small key icon on GitHub SSH will turn green after successful test

   ssh-T [email protected]_two   

   #如果配置正确会提示

    Hi your git account two  in github ! You‘ve successfully authenticated, but GitHub does not provide shell access.

4.clone Project to Local

Original operation:git clone [email protected]:yourAccount/xxx.git;

现改为:git clone [email protected]_two.com:yourAccount/xxx.git

Use multiple git accounts on a single computer

Related Article

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.