首先git checkout -- filename 恢复成的是暂存区版本 而不是版本库的版本 git add filename 将工作区文件添加到暂存区 git commit -m "explain"将暂存区所有修改同步到版本库 也就是说如果想同步版本库版本,要先用git reset HEAD <filename>将暂存区同步成版本库的版本 然后再用checkout命令 git checkout <filename>命令针对工作区 git reset HEAD filename命令针对暂存区(git restore <file>好像也是一样的作用)