检查状态,看看发生了什么:
$ git status
On branch master
Changed 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.rb
no changes added to commit (use "git add" and/or "git commit -a")
可以看出,我们删除了一个文件。但是这个改动只发生在工作区(working tree)中,还未提交到仓库。这意
味着,我们可以使用checkout 命令,并指定-f 旗标,强制撤销这次改动:
$ git checkout -f
$ git status
# On branch master
nothing to commit (working directory clean)
$ ls app/controllers/
application_controller.rb concerns/
删除的目录和文件又回来了,ohlala!

相关文章:

  • 2021-07-04
  • 2021-11-20
  • 2021-12-26
  • 2022-12-23
  • 2021-10-05
  • 2021-11-20
猜你喜欢
  • 2021-12-09
  • 2021-12-02
  • 2021-10-28
  • 2021-07-18
  • 2021-11-22
相关资源
相似解决方案