git stash命令

Posted yoyoma0355

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了git stash命令相关的知识,希望对你有一定的参考价值。

命令:git stash

    1.使用git stash 保存当前的工作现场, 那么就可以切换到其他分支进行工作,或者在当前分支上完成其他紧急的工作,比如修订一个bug测试提交。

 

    2.如果一个使用了一个git stash,切换到一个分支,且在该分支上的工作未完成也需要保存它的工作现场。再使用git stash。那么stash 队列中 就有了两个工作现场。

 

    3.可以使用git stash list。查看stash队列。

 

    4.如果在一个分支上想要恢复某一个工作现场怎么办:先用git stash list查看stash队列。确定要 恢复哪个工作现场 到当前分支。然后用git stash pop [email protected]{num}。num 就是你要恢复的工作现场的编号。

 

    5.如果想要清空stash队列则使用git stash clear。

 

    6.同时注意使用git stash pop命令是恢复stash队列中的[email protected]{0}即最上层的那个工作现场。而且使用pop命令恢复的工作现场,其对应的stash 在队列中删除。 使用git stash apply [email protected]{num}方法 除了不在stash队列删除外其他和git stash pop 完全一样。

 

     ==========================================================

    当有紧急工作时,又不想commit现在做一半的工作,就用git stash,然后就可以切换到其他分支进行紧急工作。

 

以上是关于git stash命令的主要内容,如果未能解决你的问题,请参考以下文章

git stash命令使用

每天一命令 git stash

git命令之git stash 暂存临时代码

Git stash命令详解和使用

Git stash命令详解和使用

git stash命令