Use of Git--upload and download

Configure Git username and email

If it is under Windows, choose Git Bash and complete everything on the command line, which may be a bit troublesome at first, but just remember those few command lines after using them a few times. First set up Git initially:

# 配置用户名
git config --global user.name "Your Real Name"
# 配置邮箱 	注:注册时使用的邮箱
git config --global user.email [email protected]

Validation: Enter after configuration is complete

git config --global --list

generate ssh

Enter the following command in the command line of the window and run it, click Enter continuously to generate the SSH file location. Refer to the command prompt. The default is the user folder of the system.

ssh-keygen -C '你注册时使用的邮箱' -t rsa

image-20210722143124823

location of key generation

image-20210722143214003

Add the public key ( id_rsa.pub ) in the ssh folder to the GitHub management platform, and find the following interface in the settings of GitHub's personal account

Then open id_rsa.pub with editing software (everedit and other editing software), copy the key to the following key, and then click Add SSH key to generate Figure 2

image-20210722143750413

​ Figure 1

image-20210722143946675

​ Figure 2

Test if the configuration is successful

  1. Type in Git Bash:
ssh -T [email protected]
  1. SSH warning

    When you connect to GitHub for the first time using the Git command, you will get a warning:

$ ssh -T [email protected]
The authenticity of host 'github.com (13.229.188.59)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])?

This is because Git uses the SSH connection, and the SSH connection requires you to confirm whether the fingerprint information of the GitHub Key really comes from the GitHub server when verifying the key of the GitHub server for the first time, and then press yesEnter.

Git will output a warning telling you that the GitHub key has been added to a local trust list:

Warning: Permanently added 'github.com' (RSA) to the list of known hosts.

This warning will only appear once, and subsequent operations will not have any warnings.

If you are really worried about someone pretending to be the GitHub server, yesyou can check whether the fingerprint information of GitHub's RSA Key is the same as that given by the SSH connection before entering it.

The following results show that the configuration is successful

Hi maoniya! You've successfully authenticated, but GitHub does not provide shell access

Upload the project to the github repository

1. Select the project you need to upload the code cloud warehouse

Select this item and click git bash here, and then operate in the pop-up window

image-20210728094513838

Note: Depending on individual needs, whether you store one project or multiple projects in your warehouse, the location of the local warehouse you generate when you execute git init is also different. There are two situations as follows:

1.1 The remote warehouse has only one project

image-20210728093521821

​ project folder

image-20210728093658650

1.2 The remote warehouse has multiple projects

image-20210728093949843

image-20210728094021899

At this point, the folder is used as your local warehouse, and multiple projects are stored in this folder.

2. Create a local warehouse

This repository acts as a repository for locally stored projects

git init

Initialize a local warehouse, will need to upload the project

3. Select the item to be added to the warehouse

git add maoni_MybatisDemo

If you need to upload all the files in this directory

git add  all .

. : all folders

When uploading the warehouse, if the following error occurs

warning: LF will be replaced by CRLF in pom.xml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in src/main/java/net/maoni/Mybatis/mavenDemo2Application.java.
The file will have its original line endings in your working directory

Solution:

git config --global core.autocrlf false

4. Submit to the local warehouse, remarks (not important)

 git commit -m 'springbootdemo'

-m is followed by a parameter, indicating a description. After submitting the code to GitHub, the description will be displayed on the code file information

image-20210722150406542

5. Associate the remote warehouse

 git remote add origin [email protected]:maoniya/SpringBootDemo01.git

[email protected]:maoniya/SpringBootDemo01.git is your repository address on github

image-20210722150603865

1. If an error occurs, such as

error: remote origin already exists.

2. Then enter in the git bash here window

git remote rm origin

3. Then go to resubmit

git remote add origin [email protected]:maoniya/SpringBootDemo01.git

6. Perform judgment before submitting code

If the gitee repository is created with a README.MD file, pull the code first, and skip the next step if the repository is empty

git pull --rebase origin master

7. Submit the remote repository

git push -u origin master

image-20210722151111398

Download the project

Download the project from gitee or github to the local

1. Create a directory locally to store the project files

2. Operate in the directory

image-20210722164112416

In the window enter:

 git clone '你克隆的地址'

image-20210722164159871

Guess you like

Origin blog.csdn.net/m0_49969111/article/details/119002416