GitHub and Git software use

1 Initial introduction

First of all, what are GitHub and Git? Why do we use these tools? Let's start with GitHub. If you have participated in a mathematical modeling competition, you may have all gone through this process: a team of people are responsible for different parts of a document, and then finally handed over to a classmate to summarize. At this time, due to continuous modification and improvement of the content, there may be countless names similar to "Part 1", "Part 2", "Part 3", "Revision 1", "Revision 2" and so on on everyone's computer. This kind of Word document, these many Word files undoubtedly brought a lot of troubles to the final version merging process. The Word in mathematical modeling is similar to the code file in our graduation project, and it also needs to be updated continuously. At the same time, the mathematical modeling mentioned above often only takes 3-4 days, so no matter how many Word documents are, it will not be too cumbersome; and the graduation design is different, starting from last year, and then to the present, and then to the final submission of the paper In April and May, this time span is very large. If we still use the above-mentioned stupid method of "adding a number after the file name", the final file number may be three digits; if it’s good, then we don’t add it. Numbered, modify directly on the basis of the original file, and a new problem arises-if we directly modify the code written the day before today, and save the file and exit, then we find that today’s modification is problematic , The version from the day before yesterday is more correct, but it can no longer be withdrawn, and it is not easy to manually re-adjust the modified contents one by one to the version before the previous day's modification with the help of memory. So, is it annoying? Then, GitHub can solve such troubles. A very professional introduction to GitHub is also available on the Internet. Everyone can do it on Baidu; besides, I am not a professional, so I can put it in layman's terms: GitHub is a warehouse that can manage different versions of the same file. Maybe it’s not clear to say so. I believe you will understand after reading the following table:
Insert picture description here

Yes, you read that right, each file has a one-to-one correspondence with its corresponding user, time, and version modification content, and each file can be downloaded, so you can easily go back to the version. To put it bluntly, GitHub is to achieve the above-mentioned work. And GitHub's implementation of the above work is based on an online platform. In other words, it is a website that achieves this purpose, and Git is a computer software that echoes GitHub; the two are combined to realize the use of Git software to connect the computer Upload the code file in the GitHub page.
It is worth mentioning that Git is not the only computer software that realizes this function, but it has been praised and used extensively by many programmers, so I also use it. There are also GitHub-like websites in China, such as Code Cloud Gitee (https://gitee.com/). Compared with GitHub, the speed and stability may be better. At the same time, I believe that everyone is a descendant of the dragon and supports local companies. , So everyone can try more.

2 How to use

Generally, there are two ways to use GitHub. One is to first create your own files on the GitHub web page, and then synchronize to the local computer; the other is to first complete the code file on the local computer, and then synchronize to the GitHub web page. Here I personally think that the first method is more convenient, so I take the first method as an example.

2.1 GitHub configuration

First, we log in to the official GitHub website: https://github.com/. After registering an account, click the "New" button on the left side of the screen to create a new Repositories. This Repositories is where your code and other files are stored. Then, give your Repositories a name, add a brief introduction, and other options follow the picture below. Among them, for the selection of the license, please refer to: https://zhuanlan.zhihu.com/p/51331026.
Insert picture description here

After completion, you will see that there are already README and License files in the newly created Repositories.
Then, in the Code interface in the upper left corner of the Repositories interface, select one by one according to the following figure, and copy the corresponding SSH backup.

Insert picture description here

2.2 Git configuration

First download the Git software: https://gitforwindows.org/. Then install and open. The first time you use Git, you need to set the user name and email address. I didn't have a screenshot here. You can refer to: https://www.jianshu.com/p/296d22275cdd.
Subsequently, close the Git software. We select a suitable folder, right-click here, select "Git Bash Here" to open Git, and enter the code:

git clone [email protected]:Chutj/Crop_Yield_Prediction_with_Machine_Learning.git

Here, the cloned code needs to be replaced with the SSH you copied above.
Afterwards, you can find that the README and license files generated in the foregoing operation are already in the local folder.

2.3 Upload code to GitHub

Next, we can perform code version management and upload. Write the code in the local folder, and then right-click in this folder to open Git Bash:

Insert picture description here
Take my "CropYield_DL_Old.py" file as an example, enter the code:

git add CropYield_DL_Old.py

Insert picture description here

Then enter:

git commit -m"Modify This File"

Insert picture description here

Among them, the content in quotation marks is file modification remarks, which is convenient for everyone to understand the details of each file modification, and the specific content can be modified by yourself.

As you can see, the specific information of the file modification has been listed below the code.

Finally, enter the code:

git push

Insert picture description here

About to upload the "CropYield_DL_Old.py" file we just modified to GitHub.
Insert picture description here

At this point, the simple operation of GitHub and Git has been completed.
The above content is really very rough compared with other operation tutorials on GitHub or Git on the Internet-because I am not a professional programmer, the above does not involve advanced operations of Git (such as version backtracking), etc. You can refer to two I think Very detailed tutorials for further study.
https://www.jianshu.com/p/296d22275cdd
http://res.crossincode.com/wechat/git.html

Welcome to pay attention to the public account: crazy learning GIS
Insert picture description here

Guess you like

Origin blog.csdn.net/zhebushibiaoshifu/article/details/113888067