1
錯誤我在我的git存儲庫中有一個目錄rm -rf
。這些更改沒有提交,我想恢復這個更改並返回到最後的git提交。如何恢復未被刪除的文件(用普通rm刪除)到最後的git提交
# On branch release-1
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: dir/file1
# [....]
由於文件被刪除我尼特能夠做到git checkout -- <file>
,所以我做git checkout --
代替,但這並沒有工作。
所以我參加了一個捷徑:藏匿的變化
$ git stash
Saved working directory and index state WIP on release-1: d2dbff3 removed the CVS $Id lines
Checking out files: 100% (394/394), done.
HEAD is now at d2dbff3 removed the CVS $Id lines
現在是一切OK。
我有一個印象,那就是存儲是一種強力方法。是否有可能做一個checkout
當前分支(整個沒有提供任何文件)放棄任何改變?
+1我對丟失的文件如此混淆,以至於我沒有想到將dir代替文件給checkout命令:-(,謝謝 – 2012-02-02 00:56:35