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)
$
如果觉得本文对您有帮助,不妨扫描下方微信二维码打赏点,您的鼓励是我前进最大的动力:

git命令--git checkout 之 撤销提交到暂存区的更改的更多相关文章
- Git入门 时光穿梭鸡 版本回退 工作区 暂存区
分布式集中式 CVS及SVN都是集中式的版本控制系统 , 而Git是分布式版本控制系统 集中式版本控制系统,版本库是集中存放在中央服务器的, 而干活的时候,用的都是自己的电脑,所以要先从中央服务器取得 ...
- git使用记录七:对工作区和暂存区的一些操作场景
比较暂存区和HEAD所含文件的差异? 操作场景如下: 修改readme.md 文档 vi readme.md 加入到暂存区域 git add readme.md 使用git diff -cached ...
- Git使用指南(2)——工作区,暂存区,版本库
1 工作区修改添加到暂存区 git add 2 暂存区提交到版本库 git commit 3 版本库更新到暂存区 git reset HEAD 4 删除暂存区文件 git rm --cached< ...
- Git使用详细教程(1):工作区、暂存区、本地仓库、远程仓库
之前的写过一篇如何在服务器上搭建Git服务Git服务器搭建,接下来的一段时间,我将详细的讲解Git的使用.看如下一张图片,本篇主要理解一些基本概念. 图中几个名词的意思如下: workspace: 工 ...
- git(工作区,暂存区,管理修改,撤销修改,删除文件)
工作区和暂存区 984次阅读 Git和其他版本控制系统如SVN的一个不同之处就是有暂存区的概念. 先来看名词解释. 工作区(Working Directory) 就是你在电脑里能看到的目录,比如我的l ...
- Git - 暂存区及撤销修改
1. 暂存区 每个 Git 仓库中,都有一个隐藏目录 .git 用于存放 Git 仓库的相关信息,包括暂存区(称为 stage).自动创建的 master 分支以及指向 master 分支的 HEAD ...
- git命令——git rm、git mv
git rm git rm命令官方解释 删除的本质 在git中删除一个文件,本质上是从tracked files中移除对这些文件的跟踪.更具体地说,就是将这些文件从staging area移除.然后c ...
- git命令——git status、git diff
前言 当对项目做了更改时,我们通常需要知道具体改了哪些文件,哪些文件更改了没有暂存,哪些文件改了并且已加入到暂存区等待下次commit.上述任务使用git status都可以帮我们解决.但是想要知道文 ...
- git 命令 git status add rm commit mv
1.查看 git 仓库文件改动状态 Git 仓库内文件改动有 4 种状态,除了 Unmodified 状态的文件因为并未改动默认没有状态不做显示之外,其他文件改动状态都可以通过 git status ...
随机推荐
- iOS linker command failed with exit code 1 (use -v to see invocation)多种解决方案汇总
有时可能会遇到这种错误,关键是这种错误,有时只有这一句话,也不会给更多错误信息. 网上找了一些,总结了如下:(PS:以下是按照解决简易程度排序,不代表出现概率) 1.bitcode问题 解决如下:原因 ...
- iOS绘图UIBezierPath 和 Core Graphics框架
前言 iOS系统本身提供了两套绘图的框架,即UIBezierPath 和 Core Graphics.而前者所属UIKit,其实是对Core Graphics框架关于path的进一步封装,所以使用起来 ...
- 构建高性能数据库缓存之redis主从复制
一.什么是redis主从复制? 主从复制,当用户往Master端写入数据时,通过Redis Sync机制将数据文件发送至Slave,Slave也会执行相同的操作确保数据一致:且实现Redis的主从复制 ...
- Python学习笔记(六)—— 条件判断
一.语法 if <条件判断1>: <执行1> elif <条件判断2>: <执行2> elif <条件判断3>: <执行3> e ...
- HDU 3584 Cube (三维数状数组)
Cube Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)Total Submi ...
- 使用嵌入式关系型SQLite数据库存储数据
除了可以使用文件或SharedPreferences存储数据,还可以选择使用SQLite数据库存储数据. 在Android平台上,集成了一个嵌入式关系型数据库—SQLite, 1.SQLite3支持 ...
- Cal Cat for Mac(猫咪控日历工具)安装
1.软件简介 Cal Cat 是 macOS 系统上一款猫咪控日历工具,可以将系统内置的日历工具美化成猫咪风格的日历,超级可爱的猫咪可是猫咪控的最爱了,喜欢的朋友快快用上吧. 加州猫是一个桌面集 ...
- aaronyang的百度地图API之LBS云与.NET开发 Javascript API 2.0【把数据存到LBS云1/2】
如何让用户点,我们可以获得经纬度,我们就要先了解下它给我们提供的百度地图的事件 主要有两个操作事件的,绑定(addEventListener)和解绑(removeEventListener) 一些事件 ...
- aaronyang的百度地图API之LBS云 笔记[开发准备]
我的脚印 1.注册百度账号 先到163邮箱注册个邮箱(注册邮箱),用这个邮箱注册百度账号(注册百度),激活百度账号 2.登陆百度账号,进入 百度地图 申请为LBS开发者 2.1 注册申请为百度开发者( ...
- htmlentities、addslashes 、htmlspecialchars的使用
1.html_entity_decode():把html实体转换为字符. Eg:$str = "just atest & 'learn to use '";echo htm ...