Git multi-Account Login

Source: Internet
Author: User
Tags git commands
Cancel git global settings

Many users perform global settings for git according to the tutorial on the Internet, for example:

git config --global user.name "your_name"git config --global user.email  "your_email"

If multiple projects you participate in allow you to use the same user name and email address, this setting is certainly correct. However, once you enter the company, it is estimated that you do not have the right to choose independently, the company will configure the corresponding domain account and mailbox,

Therefore, weFirst, cancel the global settings of git.

git config --global --unset user.namegit config --global --unset user.email

Then:Set the user name and email address for each project separately,The setting method is as follows:

Git config user. Name "your_name"

Git config user. Email "your_email"

To put it bluntly, go to the root directory of your git project and execute the GIT config settings record.

SSH Configuration

(1) In ~ /. In the SSH directory, use:

Ssh-keygen-t rsa-c "[email protected]"-f ~ /. Ssh/file name

Generate a public/private key for each account. The file names are project1_rsa and project2_rsa. Then, configure the public key content on the GIT Project Server (that is, the corresponding account ).
(3) In ~ /. Create the config file in the SSH directory and configure it accordingly:

Example of the basic config Syntax:

Host meilihao.github.com   HostName github.com   User git   IdentityFile ~/.ssh/id_rsa_github
At the same time, the ssh url of your GitHub repo will be modified accordingly. For example, according to the above configuration, the original connection address is:
[email protected]:meilihao/gopkg.git

According to the above configuration, we need to replace github.com with meilihao.github.com. Then, during SSH resolution, meilihao.github.com will be automatically converted to github.com. After modification, it will be:

[email protected]:meilihao/gopkg.git

To test the connection, run the following command:

Ssh-T yourhost // This is ssh-T meilihao.github.com

By the way, remember to modify the address submitted by the GIT project:

Git remote RM origin // Delete the previous configuration git remote add origin [email protected]: meilihao/gopkg. Git // configure the latest address

 

Other articles:

Meiwenyi

Common git commands

 

Git multi-Account Login

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.