Basic use of Git
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:
Git environment configuration
Next, configure the environment variables:
first check whether it is configured:
enter cmd, enter the dos operating system:
mine already exists here.
If you don’t have friends, you can reconfigure it:
Go to the system’s environment variables:
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
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).
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.
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"
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)
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.
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,
click the "OK" button in the pop-up box. Find the path of the project you want to upload.
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!)
to commit the changes
Right-click the current project name, select in the pop-up menu bar: Git->Commit Directory,
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
. 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).
For the first operation, you need to configure the server warehouse address, click Define remote in the pop-up box
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
After that, IDEA will automatically check the link, and if there is no problem, click the Push button below
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.
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.
Submitted successfully! ! !
Solution to push failure
At this point, click the IDEA test console option to open the console view:
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.