Git has three Reset Functions: soft, mixed, and hard. The differences are as follows:
LSoft-The current branch is reset to the specified commit record location, and the index and work tree remain unchanged;
LMixed-The current branch is reset to the specified commit record location, the index is updated, and the work tree remains unchanged;
LHard-The current branch is reset to the specified commit record location, and the index and work tree are updated.
It seems hard to understand. First, you must understand the three regions of git (Work tree, index area, and repository). For details, refer to git introduction.
Perform a soft test and create a soft. Java file. The file is not added to the index control.
Submit the job once, and reset the job in the history window,
View the work Tree After resetting,
It can be seen that the soft file still exists, indicating that the reset has not changed the work tree, and the soft file is not the "Question mark" icon, indicating that it has been added to the index, indicating that the index has not changed. The only reset is the history.
Create a new mixed. Java file. At this time, mixed. Java is not added to the index control, and then submit.
Reset in the history window
The result of the reset operation is as follows:
As you can see, the mixed. Java file still exists, indicating that the work tree has not changed, but the file status is untracked, indicating that the index is updated. At this time, no index control is added to the file.
Finally, let's take a look at hard reset and create a hard. Java file. At this time, no index is added to the file, and then submit the file.
Reset this submission on the history interface,
Reset and view the work tree. The result is as follows:
We can see that the hard. Java file does not exist, which indicates that the index and work tree are updated.