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)
    $

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

  • 相关阅读:
    web图片100%宽度自适应,高度不塌陷
    基于Kafka+ELK搭建海量日志平台
    一句话撸完重量级锁、自旋锁、轻量级锁、偏向锁、悲观、乐观锁等
    MySQL数据库设计规范
    夺命连环问:一个 TCP 连接可以发多少个 HTTP 请求?
    [Kafka]
    ZooKeeper学习总结 第一篇:ZooKeeper快速入门
    Vue图片浏览组件v-viewer,支持旋转、缩放、翻转等操作
    opencv处理验证码python代码
    mac使用pytesseract
  • 原文地址:https://www.cnblogs.com/jun1019/p/6656118.html
Copyright © 2011-2022 走看看