救回刪除的 branch

這禮拜在寫程式,因為跟朋友一起弄。順便教他怎麼弄git,結果不小心把自己的branch刪除了。一天的工作量就這樣消失在空氣中…(嚇死我了,我每天晚上也才兩個小時,再多也擠不出來了)。

步驟如下:

 

1. 先透過該指令 git fsck –full –no-reflogs | grep commit  找到被刪除的commit

2. git log –stat 5c6a8f1af  看一下該commit 是不是你要救回的內容

3 git checkout 5c6a   救回來( 可以先開到branch 在執行比較保險阿)

ref:

http://gigism.blogspot.com/2010/04/recover-deleted-branch-from-git.html

http://gitbook.liuhui998.com/5_9.html

發表留言