Home > Article > Development Tools > Detailed explanation of Git basics: git recovery of deleted files (detailed explanation with examples)
This article brings you relevant knowledge about Git, which mainly introduces issues related to git recovery of deleted files, including deletion operations submitted to the local library, deletion operations added When it comes to the temporary storage area, the deletion operation is all related to the work area. I hope it will be helpful to everyone.
Recommended study: "Git Tutorial"
So-called use git command to restore deleted files, provided that the file needs to be managed by git.
In other words, this file has been submitted to the repository before.
This is a basic condition.
If this file is not managed by git, deleting it is the same as deleting an ordinary file on the computer.
[Core]: The core idea of file recovery is: reset the workspace state to be consistent with the state of the version where the corresponding file exists, and the file will be back.
[Key points] Understanding the git reset --hard command
情景解释 : 工作区中删除一个文件,git add 到暂存区,git commit 提交版本库
1. Check the working directory and status
2. Delete the file, add it to the staging area, and submit Go to the repository
3. View the file directory of the workspace
4. Revert to the previous version of the file and view the files in the workspace
情景解释 :工作区中删除一个文件,git add 到暂存区
1. Check the working directory and status
2. Delete the file and add it to the temporary storage area
3. View the file directory of the workspace
4 .Restore to the version where the file existed before and view the file in the workspace
情景解释 : 工作区中删除一个文件
1. View the working directory and status
2. Delete files, only delete files in the workspace
3. View the file directory of the workspace
4. Restore to the version where the file existed before and view the files of the workspace
[Below Both methods are ok. It is recommended to use the method in Figure 2, which is also the method recommended by git】
Recommended study: " Git tutorial》
The above is the detailed content of Detailed explanation of Git basics: git recovery of deleted files (detailed explanation with examples). For more information, please follow other related articles on the PHP Chinese website!