To restore a single file, use git checkout [previously submitted commit id] -- file name. If you want to discard all files in the workspace, use git reset --hard <commit id>
git checkout -- You need to specify the file name later. If you want to undo all the uncommitted changes in your working directory, you can use git stash. This is to temporarily undo the changes and save them if you no longer need to restore them. , git stash drop will never recover.
git reset --hard <commmit hash>
To restore a single file, use git checkout [previously submitted commit id] -- file name. If you want to discard all files in the workspace, use git reset --hard <commit id>
git reset HEAD^
Revert the last commit, so that the commit is rolled back and the changes will be retained in the uncommitted state
git checkout -- You need to specify the file name later.
If you want to undo all the uncommitted changes in your working directory, you can use git stash. This is to temporarily undo the changes and save them if you no longer need to restore them. , git stash drop will never recover.