![17.png](http://upload-images.jianshu.io/upload_images/3701654-83dd8064b05c788e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
### 1.撤销修改
~~~
git checkout -- <fileName>
~~~
![18.png](http://upload-images.jianshu.io/upload_images/3701654-3376ee4be9678d26.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
### 2.删除文件[rm <file>]()
~~~
rm <File>
~~~
- 之后如果确定要删除文件,命令行中输入
![19.png](http://upload-images.jianshu.io/upload_images/3701654-47d7fa368fdf032c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
~~~
git rm test.txt;
git commit -m "remove test.txt"
~~~
- 另一种情况是删错了,因为版本库里还有呢,所以可以很轻松地把误删的文件恢复到最新版本
~~~
git checkout -- test.txt
~~~