git stash pop莉御,不同于git stash apply, 會應(yīng)用且pop出最近的一次stash,stash list不再會有之前的stash俗冻。git stash pop出的change是可以找回的.
每次git stash都會生成一個新的commit礁叔,只要知道commitID, 通過git stash apply commitID 就可以應(yīng)用之前的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中的位置確定對應(yīng)的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