git stash pop,不同于git stash apply, 會應用且pop出最近的一次stash,stash list不再會有之前的stash。git stash pop出的change是可以找回的.
每次git stash都會生成一個新的commit,只要知道commitID, 通過git stash apply commitID 就可以應用之前的stash,然后重新git stash, 那么新修改就
回到了stash list中。尋找commitID有兩種方法:
- git stash pop 最后會打印出pop掉的commitid值,若這個記錄還存在直接使用即可。
- git fsck, 會打印出所有的dangling commit, 懸掛的commit是不被任何branch引用的commit。 一般list出的第一個commit即是剛剛被pop掉的commit。也可通過查看commit在commit graph中的位置確定對應的commitID:
git log --graph --oneline $(git fsck | awk '/dangling commit/ {print $3}')
參考: http://stackoverflow.com/questions/89332/how-to-recover-a-dropped-stash-in-git