zoukankan      html  css  js  c++  java
  • 删除文件以后,如何通过git撤销删除的文件,不提交到远端代码库

    检查状态,看看发生了什么:
    $ 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!

  • 相关阅读:
    暂存
    近期学习规划
    将博客搬至CSDN
    后缀自动机五·重复旋律8
    后缀自动机四·重复旋律7
    拓扑排序
    后缀自动机三·重复旋律6
    后缀自动机二·重复旋律5
    交错和(数位dp)
    博弈专题
  • 原文地址:https://www.cnblogs.com/spicy/p/8495837.html
Copyright © 2011-2022 走看看