Install git for the first time, configure username, email address and key

Install Git on Windows:

To use Git on Windows, you can download the installer directly from the Git official website (for students with slow internet speeds, please move to the domestic mirror ), and then install it according to the default options.

After installation is complete

Type on the keyboard: windows+r and you will see:

Enter: cmd and press Enter to open the command line window, then enter: git If the following prompts appear, it means that git has been installed successfully.

After the installation is complete, you need the last step of setting, enter the following two commands on the command line:

git config --global user.name "fill in your name like lanch"       
git config --global user.email "Register git's email address such as [email protected]"

At this time, you need to download the code or upload the code to the remote warehouse. If you use it for the first time, you need to configure the ssh key for the computer.

A computer only needs to be configured once, and it does not need to be configured again in the future.

Git uses ssh keys:

Git supports two transmission protocols: https and git. When github shares links, there are two protocols to choose from:

git protocol link legend: 

https protocol link legend: 

 

Git uses the https protocol. Every time you pull or push, you will be prompted to enter a password, use the git protocol, and then use the ssh key, which saves you the trouble of entering the password every time.

 

 

 1. Generate the key

Most Git servers will choose to use an SSH public key for authorization. Each user in the system must provide a public key for authorization, and if not, generate one. The process of generating a public key is similar on all operating systems. First of all, you need to confirm whether the machine already has a public key.

The default storage location of the .ssh folder is: C:\Users\Administrator\.ssh

In some cases, delete all the files in it directly, which is what I did.

Then at the command line enter:

 

ssh-keygen -t rsa -C "Fill in the email address when registering git such as [email protected]"

Then the following prompt:

 

At this point, your local key pair is generated.

 

 

2. Add the public key to your remote repository (github)

 

1. View the public key you generated and enter the command: cat ~/.ssh/id_rsa.pub

 

2. Log in to your github account. Click on your avatar, then Settings -> left column click SSH and GPG keys -> click New SSH key

    ​

 

3. Then you copy the public key content above and paste it into the "Key" text field. In the title field, you can name it yourself.

4. Click Add key.

 

 

 

After completion, verify that the key is working properly and enter the command: ssh -T [email protected]

If, see:

Congratulations, your setup has been successful.

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325081545&siteId=291194637