一.撤銷操做html
1.未提交到暫存區 git checkout -- index.html
2.文件已提交到暫存區,但未提交到版本庫 git reset HEAD index.html
二.刪除操做git
1.未提交到暫存區 rm index.html
2.同時刪除暫存取和工做區 rm index.html git rm index.html
或者直接用 git rm -f index.html
3.刪除暫存區,不刪除工做區spa
git rm --cached iindex.html
三.恢復文件code
能夠利用git log查看提交的記錄,圖中紅框所示便是提交的版本id
若是須要將某個文件恢復到某個版本 git chekout id index.html 若是須要全部文件恢復到某個版本 git reset --hard id git reset --hard HEAD^ 恢復到上一個版本 git reset --hard HEAD~2 恢復到上兩個版本 固然,也能夠利用git reflog能夠查看恢復記錄