Git Multi-account configuration use while using GitHub and Gitoschina_ favorites

Source: Internet
Author: User
Tags using git git clone

This article is on the previous article "Git-tortoisegit Complete configuration Process" expansion, so need to have an understanding of the previous article, of course, directly down to see also can, some of which mentioned some basic operations.

"Git-tortoisegit Complete configuration Process": http://www.cnblogs.com/popfisher/p/5466174.html.

This article to configure the github.com account and Git.oschina.NET account to step-by-step demonstration in the Windows environment to configure git multiple account support is to manage multiple ssh-key on the same computer, a little more understanding of git.

Note: This article is where all the commands are executed in admin mode, that is, open the Cmd,git Bash client to run the program as an administrator. 1. Generate github.com corresponding private key public key (file address C:\Users\popfisher directory in this article)

Execute command ssh-keygen-t rsa-c email create github corresponding Sshkey, named Id_rsa_github, password 123456

Ssh-keygen-t rsa-c 774232122@qq.com

2. The same way production git.oschina.net private key public key (mailbox address can be the same, this article is the same)

Execute command ssh-keygen-t rsa-c email create github corresponding Sshkey, named Id_rsa_oschina, password 123456

Ssh-keygen-t rsa-c 774232122@qq.com

3. Copy the above files to the. SSH directory that git defaults to access (Win10 in the user directory, this article C:\Users\popfisher.ssh)

In addition to the secret key file, the config file is manually produced in the subsequent steps, and the Known_hosts file is subsequently automatically produced

4. Upload the github corresponding public key and Oschina corresponding public key to the server GitHub add SSH key as shown in the following figure:

Git.oschina.net add SSH key as shown in the following illustration:

5. Create a config text file in the. SSH directory and complete the related configuration (the most central place)

Each account is configured with a single host, each host to take an alias, each host mainly configured hostname and identityfile two properties can

Host's name can be used for their favorite name, but this will affect the GIT related commands, such as:
Host Mygithub This definition, the order is as follows, that is, git@ followed by the name of Mygithub
git clone git@mygithub:popfisher/androidrotateanim.git

HostName This is the real domain address.
Identityfile, this is Id_rsa's address.
Preferredauthentications Configure what permissions to log on authentication-can be set to Publickey,password publickey,keyboard-interactive, etc.
User Configuration uses username

Config file is configured as follows:

# Configure github.com
Host github.com                 
    HostName github.com
    identityfile C:\\users\\popfisher\\.ssh\\id_rsa_ GitHub
    preferredauthentications publickey
    User username1

# configuration git.oschina.net 
Host git.oschina.net 
    HostName git.oschina.net
    Identityfile C:\\users\\popfisher\\.ssh\\id_rsa_oschina
    preferredauthentications publickey
    User UserName2

6. Open Git Bash client (run as Administrator) Execute Test command test is configured successfully (automatically configure the private key in the. SSH directory to generate known_hosts files)

7. After the success of the test can be on the computer at the same time using Git more account to operate at the same time, do not affect the clone GitHub on the project Androidrotateanim

Open the Androidrotateanim item on GitHub and copy its corresponding clone command as shown in the following illustration

Execute the Clone command as follows:

Items on the clone oschina.net Androiddevtools

Open the Androiddevtools item on Git.oschina.Net and copy its corresponding clone command as shown in the following illustration

Execute the Clone command as follows:

Learning experience

In the process of using git, usually only focus on the single account of the situation, the work of the configuration is directly from their superiors send a configuration document and so on, and then to do it again, but when they really have this demand, suddenly found helpless. I also belong to this situation at that time, one day at home, suddenly found that they need a computer to support multiple SSH key when found that they do not know how to do it, so determined to do their own research. For technology, or to hands-on practice, the practice of things to form their own truth, it is not so easy to forget.

This article is based on my WIN10 platform practice, due to limited knowledge, may not be summed up in a very complete, but also may be on other platforms will encounter some other problems, there is no time to study, if the reader has encountered any problems, welcome message discussion, common learning.

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.