Table of contents
1. Some preparatory work before the three tricks
2. Create a java project and submit it using the three axes
1. Some preparatory work before the three tricks
1. First, we log in to gitee and create a new warehouse
2. Create a new folder locally (the projects to be submitted in the future will be placed in this folder),
This folder is equivalent to the local warehouse of our code, and the warehouse on gitee is the remote warehouse of our code
In the newly created folder, right click and select Git Bash Here
3. Enter git init in the window
At this time, there will be an additional .git folder in the folder. If you cannot see the folder, click the right mouse button and select "Show hidden files" to see this folder.
4. Enter the newly created warehouse in our gitee just now, and copy our remote warehouse link
5. Go back to the newly created local folder, continue to operate git, and enter git remote add origin + the path you just copied in Code Cloud
The meaning of this step is: Next, the project we created in the local d/java-gitee/gitee-test directory will be submitted to the remote warehouse above in the future
So how to judge that we have successfully connected to the remote warehouse? If we enter the command line above, if there is no error message in the command line, it means success (because in the command line, including in Linux, no information is the best information)
2. Create a java project and submit it using the three axes
Next, let's create a java project and submit it for a try
In the command line, continue to enter the git pull origin master command to pull the warehouse on the code cloud to the local folder—that is, the local warehouse (many people may say that this command is redundant when we operate the warehouse by ourselves. Anyway, the remote warehouse files on gitee will generally not change)
But if you accidentally change the code in your remote warehouse on gitee, isn't the code in the remote warehouse different from the local warehouse? At this time, problems are prone to occur when performing add, commit, and push operations .
Besides, when we enter the company in the future, a team will develop a project publicly. The code of the remote warehouse will change at any time, so we must pull the remote warehouse on gitee to the local warehouse before submitting.
Of course, because our remote warehouse is newly built, there is nothing on it
The preparatory work is done, and then we will officially submit the three axes
first strike
git add (the name of the project you want to submit)
Use git add . (. means all), or git add + a single file name, this step is to load the file into the buffer
Add all the data in the working directory to the workspace. (Looking at the current branch, you can find that there are new files in the temporary storage area)
Use git add to add locally modified or added files. eg: git add test.txt
second ax
git commit -m "update instructions"
The third ax
git push origin master
Use git push origin master to push the local warehouse to the remote warehouse
Finally, go back to gitee, refresh, and you can see the uploaded project
3. Some Supplements
If we modify the project, we need to perform this process again
So if we change our project code on gitee (remote warehouse), but the code on our local warehouse has not been changed synchronously at this time, then git pull origin master (pull the content of the remote warehouse) will be highlighted to the local warehouse) the importance of
let's test it
Next, let's pull the code from the remote warehouse to the local warehouse
git pull origin master
Attachment: git principles and basic commands (beginner)