今天一路 git stash drop
,本地暂存的数据全被我删掉了,然后 sb 的发现,Dropped refs/stash@{0} (534cb702c00f36afd4297e6328557cabead9600c)
是我早上刚写的,难道几百行的代码就没了吗?
git 里面有个特点,总有 后悔药,只要能找到这个 id,肯定就能将数据恢复过来。
1 | $ git stash pop 534cb702c00f36afd4297e6328557cabead9600c |
不料行不通!
1 | $ git stash apply 534cb702c00f36afd4297e6328557cabead9600c |
果然药到病除!
从这里也发现 git stash pop
和 git stash apply
是稍微有点区别的,如果 stash-list 里面包含了这个 commit 用法是一样的,否则 apply 可以将不在 stash-list 中的代码恢复到工作区。