标签:
在git svn的时候使用,提交记录的时候,有部分文件的修改不需要commit。
在向svn进行git svn dcommit的时候,必须保存本地目录是clean的。所以需要进行stash,然后在dcommit
dcommit之后,需要在git stash aply
之前一直都在使用git stash 以及git stash apply
但是一直没有深入的研究,今天发现git stash是是会覆盖掉之前的stash的
git stash --help 查看帮助手册
或者查看官网的帮助手册,更详细https://git-scm.com/book/en/v1/Git-Tools-Stashing
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 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:
标签:
原文地址:http://www.cnblogs.com/chucklu/p/4793715.html