一.撤销操作
1.未提交到暂存区 git checkout -- index.html

2.文件已提交到暂存区,但未提交到版本库 git reset HEAD index.html

二.删除操作
1.未提交到暂存区 rm index.html

2.同时删除暂存取和工作区 rm index.html git rm index.html

或者直接用 git rm -f index.html
3.删除暂存区,不删除工作区
git rm --cached iindex.html
三.恢复文件
可以利用git log查看提交的记录,图中红框所示即是提交的版本id

如果需要将某个文件恢复到某个版本 git chekout id index.html 如果需要所有文件恢复到某个版本 git reset --hard id git reset --hard HEAD^ 恢复到上一个版本 git reset --hard HEAD~2 恢复到上两个版本 当然,也可以利用git reflog可以查看恢复记录