最近不得已用了IDE開發,在使用裏面的git的時候不知道怎麼commit,然後瞎點了個儲藏,然後發現我的所有代碼都不見了,爲了恢復文件,我又不小心點了全部刪除,之後代碼就真的全沒了2333
從網上了解到,儲藏這個機制在git裏面對應git stash,用於臨時存儲一些文件,保存狀態,那麼不小心刪除的stash怎麼恢復呢?方法如下:
git stash apply $stash_hash
至於這裏的 $stash_hash怎麼找,windows和linux裏面有不同的方法:
在linux中:
git fsck --no-reflog | awk '/dangling commit/ {print $3}'
在windows 的powershell中:
git fsck --no-reflog | select-string 'dangling commit' | foreach { $bits = $_ -split ' '; echo $bits[2];}