git stash

git stash

用法:
git stash 储存当前修改
git stash list 查看当前所有的储存
git stash apply 应用最新的储存,(不要求在相同分支,如果储存和当前目录的修改有冲突,可以解决冲突)
git stash apply stash@{2} 选择应用哪个stash
git stash apply --index 如果当前目录有修改,再应用时同时将本地的修改也更新到stash中
git stash drop 使用apply时,只是取出stash,并未将stash drop掉,可以用drop丢掉某个stash
git stash pop 作用相当于先使用apply,再用drop
取消储藏:没有提供直接的命令,可以通过取消储藏的补丁实现,git stash show -p stash@{0} | git apply -R
从储藏中创建分支:有时,你在stash后的分支做了许多其它工作,你想重新应用储藏时可能遇到一些问题,可以以当时应用的那个储藏的commit创建一个分支,再在这个分支上应用储藏, git stash branch new_brach_name

posted @ 2018-11-09 17:25  bairuiworld  阅读(173)  评论(0编辑  收藏  举报