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命令进行代码管理时,因为自己一时疏忽直接把自己一天的劳动成果给弄丢了,这还了得,吓死宝宝了.真的,相信有代码丢失的朋友肯定能体会我当时的心情,不能体会我心情的那就祝你们也丢次代码, ...
随机推荐
- 关于ContentProvider的批量操作
今天看公司代码,发现在批量插入通话记录和联系人的时候,用了一个 ArrayList<ContentProviderOperation> ops = new ArrayList<Con ...
- Android Studio快捷键快速入门
调整,Settings->IDE Settings->Editor->Appearance->Show line numbers 显示代码行数Settings->IDE ...
- PhotoView开源项目剖析
http://blog.csdn.net/wu928320442/article/details/43056731 介绍 上一节呢,我们介绍了怎么下载和编译Android源码,这节呢,我们来讨论Pho ...
- Java根据出生年月日获取到当前日期的年月日
源码链接:http://pan.baidu.com/s/1sj61IUD
- WPF动画之关键帧动画(2)
XAML代码: <Window x:Class="关键帧动画.MainWindow" xmlns="http://schemas.microsoft.com/win ...
- 一些简单的帮助类(2)-- JavaSctipt Array Linq
在日程工作中经常会遇到这样的问题 一个JS数组 我们要找出其中 一些符合要求的类容 又或者对数组里的类容求和求平均数之类的一般的做法是循环里面的类容做判断添加到一个新的集合里 var array = ...
- C语言链表全操作(增,删,改,查,逆序,递增排序,递减排序,链式队列,链式栈)
一,数据结构——链表全操作: 链表形式: 其中,每个节点(Node)是一个结构体,这个结构体包含数据域,指针域,数据域用来存放数据,指针域则用来指向下一个节点: 特别说明:对于单链表,每个节点(Nod ...
- Linux Master/Baremetal Remote 配置下的裸机调试
为了实现在ZC702开发板上的两颗Cortex-A9处理器上实现Linux Master/Baremetal Remote 配置,并对Remote端的裸机程序进行调试,需要注意的几点如下: 一.建立p ...
- linux bash shell中case语句的实例
本文介绍下,在bash shell编程中,有关case语句的一个例子,学习下case语句的用法,有需要的朋友参考下. 本文转自:http://www.jbxue.com/article/13377.h ...
- C# 程序关闭和进程关闭
this.Close(); 只是关闭当前窗口,若不是主窗体的话,是无法退出程序的,另外若有托管线程(非主线程),也无法干净地退出: 2.Application.Exit(); 强制所有消息中止, ...