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

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

  • 相关阅读:
    CnForums1.0 Alpha 开始试运行
    asp.net Forums2.0修改密码后无法登陆问题——都是Cache惹的祸
    CnForums1.0 Alpha RC1 发布
    Docker: Nvidia Driver, Nvidia Docker 推荐安装步骤
    Docker: docker pull, wget, curl, git clone 等如何更快?
    DL4J实战之三:经典卷积实例(LeNet5)
    纯净Ubuntu16安装CUDA(9.1)和cuDNN
    DL4J实战之四:经典卷积实例(GPU版本)
    JAVA 中静态块、静态变量加载顺序详解
    设计模式之单例模式
  • 原文地址:https://www.cnblogs.com/jun1019/p/6656118.html
Copyright © 2011-2022 走看看