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