Table of contents
The first step is to create a new remote warehouse on github
The second step is to clone to a local folder
Step 3 IDEA (PyCharm as an example) integrates Git
1. Version control
Concept : Version control refers to the management of file changes such as various program codes, configuration files, and documentation during the software development process, and is one of the core ideas of software configuration management.
Why version control is needed : It is well understood that any project in the work cannot be completed at one time, and it always needs to be continuously iterated and updated. This process will continue to produce new and old version replacements. In order to complete the replacement smoothly, it is necessary to control and manage the content of each version, which is why version control exists.
Classification : Version control includes three categories, namely local version control, centralized version control and distributed version control.
Local version control : It is to manage all the files of the project locally. For example, we will use different names to distinguish the file names of different versions, and form a series of version files locally.
Centralized version control : All historical versions are stored in the central server, and the local computer can only obtain the historical versions if it is connected to the Internet.
Distributed version control : The server and each local computer maintain historical versions, so access to historical versions and project updates can be realized without networking. The downside is increased space consumed by local storage and risk of project leaks.
2. Version controller
Common version controllers include Git, SVN, CVS, VSS, TFS, etc. Among them, Git is the most advanced distributed version controller in the world; SVN is a commonly used centralized version control tool.
3. Git
1. Git download and install
Baidu git, the first is the official website of git. Click the button below to download
2. Git configuration
After downloading Git, it is recommended to use the Git Bash tool for subsequent operations. The following is the operation to view the Git configuration
Because I have configured the username and email address before, it will be displayed directly here. If you are a new user, you can use the following command to configure (just configure the user name and email address):
git config global user.name "xxx"
git config global user.email "xxx"
3. Git basic principles (core)
As shown in the figure below, there are three commands to complete the project from the local workspace to the remote warehouse.
Workspace: the folder where project files are stored in your computer
Cache area: a snapshot (information introduction) of all files in the work area, in fact it is just a file, saving the information that will be submitted to the file list
Local warehouse: It stores the data submitted to all versions, where HEAD points to the latest version put into the warehouse
Workflow: Add and modify files in the working directory; put the files that need version management into the temporary storage area; submit the files in the temporary storage area to the git warehouse. Therefore, files managed by git generally have three states: modified (modified), staged (staged), and committed (committed)
4. Git ignore file
Not all files of the project need to be submitted. You can create a file named .gitignore and write the files that need to be ignored when submitting. The specific ignore syntax can be checked online by yourself.
4. Project practice
The first step is to create a new remote warehouse on github
Created successfully!
The second step is to clone to a local folder
As shown in the picture below, I cloned the project created above to my e disk
The local situation is shown in the figure below, which is the same as the remote warehouse, so this is my local warehouse (created by cloning)
Step 3 IDEA (PyCharm as an example) integrates Git
1. First create any project (a different name is deliberately taken here)
At this point, you can find that there are no Git-related icons in IDEA
Next, we copy all the learn_git files cloned before to git_study
You can find more git icons
2. The following is the submission operation
Display the message of successful submission (note that it is only submitted to the local warehouse at this time, and the remote warehouse, that is, github, is not updated)
3. Push and push the commit to the remote warehouse
Below you can see that the push was successful