Two ways of git clone
1. https method
Common commands: git clone https://github.com/18602435706/test.git
If you want to push after clone, you generally need to enter the account password, which is very troublesome to enter each time, so:
Solution 1:
Modify C:\Users\Administator\.gitconfig
[user]
name = bossqiu //你的用户名
email = [email protected] //你的git邮箱账号
[credential]
helper = store
Solution 2:
git bash 输入 git config --global credential.helper store
2. SSH mode
Common commands: git clone [email protected]:18602435706/test.git
Note: This method can only be used if ssh is configured
Configuration method:
1. Generate sshkey according to the following command
ssh-keygen -t rsa -C "[email protected]" // 后边是你的邮箱地址
Here is [email protected]
only the name of the generated sshkey, and does not restrict or require a specific name to be a mailbox.
Most of the tutorials on the live web explain the use of mailbox generation. The original intention at the beginning was only to facilitate identification, so the mailbox was used.
2. /.ssh/id_rsa.pub
Obtain your public key by viewing the content of the C:\Users\Administator file
Or enter in git bash
cat ~/.ssh/id_rsa.pub
Copy the generated ssh key, and add the generated public key to github through the following steps.
3. Enter ssh -T [email protected] in git bash
For the first use, you need to confirm and add the host to the local SSH trusted list. If the Hi XXX! You've successfully authenticated, but Github.com does not provide shell access.
content is returned , the addition is successful.
4. Git configures multiple SSH-Keys
When there are multiple git accounts, such as:
a. A gitee, used for the company's internal work development;
b. A github, used for some development activities;
1. Generate an SSH-Key for the company
ssh-keygen -t rsa -C '[email protected]' -f ~/.ssh/gitee_id_rsa
2. Generate an SSH-Key for github
ssh-keygen -t rsa -C '[email protected]' -f ~/.ssh/github_id_rsa
3. Create a new config file in the ~/.ssh directory and add the following content (where Host and HostName fill in the domain name of the git server, and IdentityFile specifies the path of the private key)
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee_id_rsa
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_id_rsa
4. Use the ssh command to test separately
ssh -T [email protected]
ssh -T [email protected]
Take gitee as an example. If it succeeds, it will return to the following figure.