zoukankan      html  css  js  c++  java
  • git命令--git checkout 之 撤销提交到暂存区的更改

    SYJ@WIN-95I6OG3AT1N /D/gitlab/ihr-kafka-produce (master)
    $ git status      【由于工作区文件被修改了,所以显示为红色】
    On branch master
    Your branch is up-to-date with 'origin/master'.
    
    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)
    
            modified:   ihr-producer/src/main/resources/spring/applicationContext-producer.xml
    
    no changes added to commit (use "git add" and/or "git commit -a")
    
    SYJ@WIN-95I6OG3AT1N /D/gitlab/ihr-kafka-produce (master)
    $ git add .
    
    SYJ@WIN-95I6OG3AT1N /D/gitlab/ihr-kafka-produce (master)
    $ git status        【由于文件被添加到了暂存区,等待提交,所以显示为绿色】
    On branch master
    Your branch is up-to-date with 'origin/master'.
    
    Changes to be committed:
      (use "git reset HEAD <file>..." to unstage)
    
            modified:   ihr-producer/src/main/resources/spring/applicationContext-producer.xml
    
    
    SYJ@WIN-95I6OG3AT1N /D/gitlab/ihr-kafka-produce (master)
    $ git reset HEAD .
    Unstaged changes after reset:
    M       ihr-producer/src/main/resources/spring/applicationContext-producer.xml
    
    SYJ@WIN-95I6OG3AT1N /D/gitlab/ihr-kafka-produce (master)
    $ git status          【由于使用"git reset HEAD ."又撤销了前面所做的所有的add操作,所以这里又恢复到红色】
    On branch master
    Your branch is up-to-date with 'origin/master'.
    
    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)
    
            modified:   ihr-producer/src/main/resources/spring/applicationContext-producer.xml
    
    no changes added to commit (use "git add" and/or "git commit -a")
    
    SYJ@WIN-95I6OG3AT1N /D/gitlab/ihr-kafka-produce (master)
    $ git checkout .        【撤销对工作区所做的一切更改,这样以前所有的修改就都没有,慎用!】
    
    SYJ@WIN-95I6OG3AT1N /D/gitlab/ihr-kafka-produce (master)
    $ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    
    nothing to commit, working directory clean
    
    SYJ@WIN-95I6OG3AT1N /D/gitlab/ihr-kafka-produce (master)
    $

    如果觉得本文对您有帮助,不妨扫描下方微信二维码打赏点,您的鼓励是我前进最大的动力:

  • 相关阅读:
    C#之线程
    C#反射与进程
    C# XML文件的读取
    超简单的js实现提示效果弹出以及延迟隐藏的功能
    使用JavaScript随机生成数字混合字母的验证码
    用JavaScript写一个简单的倒计时,可以应用在发送短信验证码的“59秒后重新发送验证短信”
    php中curl、fsockopen的应用
    待研究
    做网站用UTF8还是GB2312?
    ECshop 数据库表结构
  • 原文地址:https://www.cnblogs.com/jun1019/p/6656118.html
Copyright © 2011-2022 走看看