天天看点

git stash保存修改

本地有修改如果更新代码会有冲突,可以利用git stash保留当前的修改

(1)git stash save "save message"  : 执行存储时,添加备注,方便查找,只有git stash 也要可以的,但查找时不方便识别。

(2)git stash list  :查看stash了哪些存储

(3)git stash show :显示做了哪些改动,默认show第一个存储,如果要显示其他存贮,后面加[email protected]{$num},比如第二个 git stash show [email protected]{1}

(4)git stash show -p : 显示第一个存储的改动,如果想显示其他存存储,命令:git stash show  [email protected]{$num}  -p ,比如第二个:git stash show  [email protected]{1}  -p

(5)git stash apply :应用某个存储,但不会把存储从存储列表中删除,默认使用第一个存储,即[email protected]{0},如果要使用其他个,git stash apply [email protected]{$num} , 比如第二个:git stash apply [email protected]{1} 

(6)git stash pop :命令恢复之前缓存的工作目录,将缓存堆栈中的对应stash删除,并将对应修改应用到当前的工作目录下,默认为第一个stash,即[email protected]{0},如果要应用并删除其他stash,命令:git stash pop [email protected]{$num} ,比如应用并删除第二个:git stash pop [email protected]{1}

(7)git stash drop [email protected]{$num} :丢弃[email protected]{$num}存储,从列表中删除这个存储

(8)

git stash clear :

删除所有缓存的stash

新增的文件,直接执行stash是不会被存储的,可以先执行下git add 加到git版本控制中,然后再git stash

reference:

[1]. https://www.cnblogs.com/zndxall/archive/2018/09/04/9586088.html