Git reset -- hard <commit>: 1. replace the referenced point. the reference points to the new submission ID. 2. replace the temporary storage area. after replacement, the content of the temporary storage area is the same as the folder tree to which the reference points. 3. replace the workspace. after replacement, the content of the workspace becomes the same as that of the temporary storage area, and is the same as that of the folder tree pointed to by the head.
Git reset -- soft <commit>: 1. Replace the referenced point. The reference points to the new commit ID. That is, only the reference point is changed. The temporary storage zone and workspace should not be edited.
Git reset -- mixed <commit> or git reset <commit>: 1. replace the referenced point. the reference points to the new submission ID. 2. replace the temporary storage area. after replacement, the content of the temporary storage area is the same as that of the folder tree to which the reference points. That is, the reference point is changed and the temporary storage area is reset, but the workspace remains unchanged.
Example: git reset only uses the folder tree pointed to by the head to reset the temporary storage area. The workspace is not affected. It is equivalent to removing the content previously updated to the temporary storage area by using the GIT add command. the reference has not changed, because the reference is reset to the head, it is equivalent to not reset.
Git reset head same as above
Git reset -- filename only removes modifications to the file filename from the temporary storage area. Other files in the temporary storage area should not be changed. This is equivalent to reverse operations of git add filename.
Git reset head filename same as above
Git reset -- soft head ^ The workspace and temporary storage area do not change, but the reference is rolled back once. if you submit a description of the latest submission or submit any changes, cancel the latest submission and submit it again and again.
Git reset head ^ The workspace remains unchanged, but the staging area will be rolled back to the previous commit, and the reference will also be rolled back.
Git reset -- mixed head ^ same as above
Git reset -- hard head ^ permanently revokes recent submissions. the reference is rolled back to the previous one, and both the workspace and the temporary storage area are rolled back to the last submitted state. all submissions since the last time are lost.
Certificate --------------------------------------------------------------------------------------------------------------------------------------
Git checkoutGit checkout <commit> [--] <paths> 1. <commit> is optional. If omitted, it is equivalent to checking out from the temporary storage area. unlike the reset command, the default value for resetting is head, and the default value for checking out is the temporary storage zone. 2. therefore, resetting is generally used to reset the temporary storage area (unless -- hard is used, the workspace is not reset), and the check-out command overwrites the workspace (assuming <commit> is not omitted, will also replace the files in the temporary storage area ). 3. this command does not change the header pointer of the head. It is mainly used to specify the version number file to overwrite the corresponding file in the workspace. if <commit> is omitted, files in the temporary storage area will overwrite the files in the workspace. Otherwise, the files in the specified commit will overwrite the files in the temporary storage area and workspace.
Git checkout <branch> 1. the head pointer will be changed. the reason behind the number of splits <branch> is that only one head can be switched to a branch to track the submission, otherwise it will still enter the "split header Pointer" state. submissions in the "separated header Pointer" status cannot be referenced and associated, which may be lost. therefore, this command is mainly used to switch branches. 2. if <branch> is omitted, the workspace status is checked.
Instance: git checkout branch checks out the branch, updates the head to point to the branch, and updates the staging area and workspace with the tree that branch points.
Git checkout summarizes and displays the differences between the workspace and the temporary storage zone and the head.
Git checkout head same as above
Git checkout -- filename uses the filename file in the temporary storage area to overwrite the filename file in the workspace. This is equivalent to canceling local changes since the last time git add filename was run (assumed to have been run ).
Git checkout Branch -- filename keeps the head point unchanged. Replace filename in the commit to which branch points with the file corresponding to the temporary storage area and workspace. the filename in the temporary storage area and workspace is overwritten directly.
Git checkout --. Or git checkout. All local changes will be canceled, which is equivalent to directly overwriting local files with all files in the temporary storage area.
Git reset and git checkout