git stash的使用
https://git-scm.com/docs/git-stash
在git svn的时候使用,提交记录的时候,有部分文件的修改不需要commit。
在向svn进行git svn dcommit的时候,必须保存本地目录是clean的。所以需要进行stash,然后在dcommit
dcommit之后,需要在git stash aply
之前一直都在使用git stash 以及git stash apply
但是一直没有深入的研究,今天发现git stash是是会覆盖掉之前的stash的[stash apply仅仅取出最近的一次stash]
git stash --help 查看帮助手册
Use git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.
The modifications stashed away by this command can be listed with git stash list, inspected with git stash show, and restored (potentially on top of a different commit) with git stash apply. Calling git stash without any arguments is equivalent to git stash save. A stash is by default listed as "WIP on branchname …", but you can give a more descriptive message on the command line when you create one.
The latest stash you created is stored in refs/stash; older stashes are found in the reflog of this reference and can be named using the usual reflog syntax (e.g. stash@{0} is the most recently created stash, stash@{1} is the one before it,stash@{2.hours.ago} is also possible).
git stash list
查看之前缓存的所有stash
$ git stash list
stash@{0}: WIP on temp: 36b0f5f 删除HSDataFrameManager类中多余的代码 //第二次的stash,覆盖了第一次【git stash apply的时候,只能出现这一次的,上一次的不会出现】
stash@{1}: WIP on temp: 36b0f5f 删除HSDataFrameManager类中多余的代码 //第一次的stash
stash@{2}: WIP on temp: c723e17 接收到消息的时候,打印出消息类型,如果消息内部有
stash@{3}: WIP on temp: 18fa2a3 连接通讯模块时,需要将主窗体的窗口句柄传递给通讯
temp是分支的名字
第0个和第1个虽然看起来完全一样,但实际上是不同的
git stash show
查看list中的某一次stash
$ git stash show stash@{0}
ZBMYun/SourceCode/ZITakerHS/ZITaker/SystemConfig.ini | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
$ git stash show stash@{1}
ZBMYun/SourceCode/ZITakerHS/ZITaker/UI/Main.cs | 2 +-
ZBMYun/SourceCode/ZITakerHS/ZITaker/ZbmStorage_Component.ini | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
git stash show stash@{0} -u
添加-u参数可以输出某一次stash的所有文件差异对比
git stash apply
可以apply指定的stash,如果你不指定的话,默认apply最近一次的stash
If you want to apply one of the older stashes, you can specify it by naming it, like this: git stash apply stash@{2}.
If you don’t specify a stash, Git assumes the most recent stash and tries to apply it:
git stash drop
$ git stash list
stash@{0}: WIP on local: 63b9f1b DebugInfoManager类,在FormMain加载的时候需要主
stash@{1}: WIP on svn: 78ab728 设备第一次上线后,直接发送采集数据,在这种情况下
$ git stash drop stash@{0}
Dropped stash@{0} (1136bc142780259d8541c7e3a605ff2250cc9427)
pop [--index] [-q|--quiet] [<stash>]
Remove a single stashed state from the stash list and apply it on top of the current working tree state, i.e., do the inverse operation of git stash save. The working directory must match the index.
Applying the state can fail with conflicts; in this case, it is not removed from the stash list. You need to resolve the conflicts by hand and call git stash drop manually afterwards.
If the --index option is used, then tries to reinstate not only the working tree’s changes, but also the index’s ones. However, this can fail, when you have conflicts (which are stored in the index, where you therefore can no longer apply the changes as they were originally).
When no <stash> is given, stash@{0} is assumed, otherwise <stash> must be a reference of the form stash@{<revision>}.
Options:
save [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [<message>]
Save your local modifications to a new stash, and run git reset --hard to revert them.
The <message> part is optional and gives the description along with the stashed state.
For quickly making a snapshot, you can omit both "save" and <message>, but giving only <message> does not trigger this action to prevent a misspelled subcommand from making an unwanted stash.
If the --keep-index option is used, all changes already added to the index are left intact.
If the --include-untracked option is used, all untracked files are also stashed and then cleaned up with git clean, leaving the working directory in a very clean state.
If the --all option is used instead then the ignored files are stashed and cleaned in addition to the untracked files.
git stash的使用的更多相关文章
- Git Stash紧急处理问题,需要切分支
在开发过程中,大家都遇到过bug,并且有些bug是需要紧急修复的. 当开发人员遇到这样的问题时,首先想到的是我新切一个分支,把它修复了,再合并到master上. 当时问题来了,你当前正在开发的分支上面 ...
- git stash 用法
git stash用于将当前工作区的修改暂存起来,就像堆栈一样,可以随时将某一次缓存的修改再重新应用到当前工作区. 一旦用好了这个命令,会极大提高工作效率. 直接举例说明: 1.准备工作,首先初始 ...
- git stash和git stash pop
git stash 可用来暂存当前正在进行的工作, 比如想pull 最新代码, 又不想加新commit, 或者另外一种情况,为了fix 一个紧急的bug, 先stash, 使返回到自己上一个comm ...
- git stash -u 添加新文件
git 提交 有新文件执行 git stash -u ------ 如果已经执行git stash,会发现有UNtracked这个单词 说明新文件没有添加进去,此时 执行 git stash ...
- 每天一命令 git stash
git stash 命令是用于保存当前进度的命令.该命令会保存当前工作区的改动.保存的改动是已经跟踪的文件的改动,对于未跟踪的改动stash是不会保存的. git stash 命令常用于分支切换的 ...
- git stash提交PR的正确步骤&git squash技术
1.git stash梳理 1.1git stash的克隆与同步 首先整理下git stash的逻辑是这样 在本地做出了新的修改,提交时显示当前的版本不是最新版本,这时就需要先pull一下自己代码仓库 ...
- git merge git pull时候遇到冲突解决办法git stash
在使用git pull代码时,经常会碰到有冲突的情况,提示如下信息: error: Your local changes to 'c/environ.c' would be overwritten b ...
- git stash简介
原文:http://gitbook.liuhui998.com/4_5.html 一.基本操作 当你正在做一项复杂的工作时, 发现了一个和当前工作不相关但是又很讨厌的bug. 你这时想先修复bug再做 ...
- Git stash 常见用法
Git stash git stash这个命令可以将当前的工作状态保存到git栈,在需要的时候再恢复 1.1 git stash 保存当前的工作区与暂存区的状态,把当前的工作隐藏起来,等以后需要的时 ...
- git stash恢复
今天下午在使用Git命令进行代码管理时,因为自己一时疏忽直接把自己一天的劳动成果给弄丢了,这还了得,吓死宝宝了.真的,相信有代码丢失的朋友肯定能体会我当时的心情,不能体会我心情的那就祝你们也丢次代码, ...
随机推荐
- 【转】【SQL SERVER】怎样处理作业中的远程服务器错误(42000)
(SQL SERVER)怎样处理作业中的远程服务器错误(42000) 问: 1.我创建了一个链接服务器. 2.在两台服务器之间创建了新的SQL用户. 3.编写了访问链接服务器的SQL语句,执行成功. ...
- Haproxy配置参数
HAProxy配置中分成五部分内容,当然这些组件不是必选的,可以根据需要选择部分作为配置. ===================== global 参数是进程级的,通常和操作系统(OS)相关. ...
- linux命令打开程序
evince 打开pdf firefox 打开浏览器
- com和dll(一)
1.com为一种规范,使不同语言能在二进制层面上进行交互. 2.dll为ms的一种程序打包文件,使程序的代码能分开打包编译,并能在运行时共享.
- 八卦某 G 的前端开发方式及流程
他山之石,可以攻玉. 话说本人从毕业到现在一直在某 B 公司工作,前些年折腾过不少开发方式和工具,但总觉得或许有更好的方案,所以很好奇其它公司内部是如何工作的,我曾经浏览过某 Y 公司内部无所不包 ...
- Gradle教程之任务管理
简要概述依赖管理 不算完美的依赖管理技术 自动管理依赖的重要性 自动依赖管理面临的挑战 声明依赖 外部模块依赖 文件依赖 配置远程仓库 这一章我将介绍Gradle对依赖管理的强大支持,学习依赖分组和定 ...
- CentOS6.5下docker的安装及遇到的问题和简单使用
Docker是一个开源的应用容器引擎,可以轻松的为任何应用创建一个轻量级的.可移植的.自给自足的容器.利用Linux的LXC.AUFS.Go语言.cgroup实现了资源的独立,可以很轻松的实现文件.资 ...
- 【原创】QT编程 多线程
请先保证已安装QT,没有请参考 http://www.cnblogs.com/kavs/p/4608926.html 安装QT. 新建threads文件夹存放项目:mkdir threads sud ...
- android BitmapFacty.Options的用法
通常我们在开发android应用程序时,在加载图片时常常需要与Bitmap打交道,一般会使用BitmapFactory中提供的相关decode方法获取: 如果一张很大的图片,我们不加处理直接decod ...
- ES6笔记-字符串方法
字符串检索方法,indexOf(searchValue,fromIndex)//参数1必需,检索查询的字符串或者值,参数2选题,规定检索的起始位置,不设置默认从0开始 indexOf()方法返回检索字 ...