使用svn的时候,回滚文件直接使用svn revert
即可,
使用git的时候,也可以回滚,具体使用如下:
第一种情况 未运行git add,回滚一个文件
$ git status -s
M test.c
$ git checkout -- test.c // git revert
$ git status -s```
##第二种情况 运行了git add,回滚整个工程
```$ echo test >> test.c
$ git add test.c // here is the different
$ git status -s
M test.c
$ git reset --hard HEAD // git revert, clean all tree
$ git status -s```
##第三种情况 运行了git add,回滚一个文件
```$ git add test.c main.c
$ git status -s
M test.c
M main.c
$ git reset test.c // unstage the change
$ git checkout test.c // discard the unstaged change
$ git status -s```
#PS:
[reverting-changes-git](http://www.szakmeister.net/blog/2011/oct/12/reverting-changes-git/)
#打赏
如果这篇文章解决了您的问题,让我买根烟抽抽。

