Detailed interpretation of the use of git combined with idea - a must-see for beginners

Welcome to Git

Hello! Welcome to Git~~

Git download and installation

Git download: Git 2.33.0.2 Windows
official website download
Official website download 2
If you want to install it, you can install it like a fool, just click Next.
After installation:
insert image description here
insert image description here

Git environment configuration

Next, configure the environment variables:
first check whether it is configured:
enter cmd, enter the dos operating system:
insert image description here
insert image description here
mine already exists here.
If you don’t have friends, you can reconfigure it:
Go to the system’s environment variables:
insert image description here
insert image description here
Note: Set it according to your installation path
. In this case, after the configuration is complete, re-enter cmd to test. If git information appears, the basic configuration is successful~~~

Git configuration under idea


Configure Git menu bar sequence selection in IntelliJ IDEA : File->Settings, select Git in the following figure in the pop-up box
insert image description here

Then click the browse icon (small folder) on the right side of the input box Path to Git executable: on the upper right, and locate the executable program of git (the git.exe file is in the cmd folder under the git installation directory).
insert image description here

Click the Test button. If the version number can be displayed after clicking, it means that the configuration is successful. At this time, click the OK button on the lower side of the window.
insert image description here

Pushing projects with Git in IntelliJ IDEA

Go to gitee website to register user
gitee website address: https://gitee.com/

github website address: https://github.com/

1 Create a warehouse
The following uses gitee as an example to introduce, and the operation of github is similar.

Create warehouse

Click "+" at the top right of the page and select "Create Warehouse"
insert image description here
to set warehouse related information

First enter the warehouse name, which can usually be the same as the project name in IDEA. Whether it is open source or not can be selected according to the needs. The private selected here (the project can only be seen by yourself)
insert image description here
is private by default. You can set it as open source after the creation is completed.
Then click the "Create" button below.
At this point, the warehouse creation work has been completed on gitee.

Copy the current warehouse path, which needs to be used later when IDEA uploads the project.

insert image description here

Import the project into version control in IDEA

Select in order in the IDEA menu bar: VCS->Import into Version Controlp->Create Git Repository

The purpose is to create a git warehouse locally first,
insert image description here
click the "OK" button in the pop-up box. Find the path of the project you want to upload.
insert image description here
Right-click the project name, and select in order in the pop-up menu bar: Git->Add

The purpose is to add the content that is not in the local warehouse in the current project to the local warehouse (in fact, it is not really added, it will only be added in the next step, but all files that are not in the warehouse need to be added before they can pass the following steps to add to the repository!)
insert image description here
to commit the changes

Right-click the current project name, select in the pop-up menu bar: Git->Commit Directory,
insert image description here
and then enter the comments for this submission, for example: the first submission (Note: You must enter content here, otherwise you cannot submit). Then click the Commit button to submit locally.

Purpose: The purpose of submission is to save the current project in the local warehouse
insert image description here
. After that, click 1:Project on the left side bar of IDEA to return to the project structure view and
right-click the project name, and select in order in the pop-up menu bar: Git->Repository- >Push

The purpose is to synchronize the content saved in the local warehouse to the server (upload to the server, and make the warehouse in the server consistent with the content of the local warehouse).
insert image description here
For the first operation, you need to configure the server warehouse address, click Define remote in the pop-up box

insert image description here
In the URL input box in the pop-up box, add the warehouse path created on gitee (the warehouse path copied on the page in the first big step and the last small step), and click the OK button

insert image description here
After that, IDEA will automatically check the link, and if there is no problem, click the Push button below
insert image description here

insert image description here
When submitting for the first time, you are required to enter the account number and password on gitee. After entering, you can select Remember to remember the password, and you do not need to enter it later.
insert image description here
Enter the username and password registered in your own git.

At this point, the submission is completed, and a prompt will be displayed at the bottom right.
insert image description here
Submitted successfully! ! !
insert image description here

Solution to push failure

insert image description here
At this point, click the IDEA test console option to open the console view:
insert image description here
execute the following three commands in the console in sequence:

git pull
git pull origin master
git pull origin master --allow-unrelated-histories

Then try to push again.

Guess you like

Origin blog.csdn.net/weixin_43639180/article/details/125877228