检查状态,看看发生了什么:
$ git statusOn branch masterChanged but not updated:(use "git add/rm <file>..." to update what will be committed)(use "git checkout -- <file>..." to discard changes in working directory)deleted: app/controllers/application_controller.rbno changes added to commit (use "git add" and/or "git commit -a")可以看出,我们删除了一个文件。但是这个改动只发生在工作区(working tree)中,还未提交到仓库。这意味着,我们可以使用checkout 命令,并指定-f 旗标,强制撤销这次改动:$ git checkout -f$ git status# On branch masternothing to commit (working directory clean)$ ls app/controllers/application_controller.rb concerns/删除的目录和文件又回来了,ohlala!