After git add .
I ran git rm -r -f .
,并且我的所有本地文件都被意外删除。
恢复它们后git fsck --lost-found
I have this http://paste.ubuntu.com/26162239 in lost-found/other
目录:
git fsck --full
notice: HEAD points to an unborn branch (master)
Checking object directories: 100% (256/256), done.
notice: No default references
dangling blob 0453ac74117a3e02ae1169ac28e6df356baec5b6
dangling blob 871364bedccaa2c57054509feeb60955e70bd141
dangling blob c38f2c2aead5f278b7680a0629ee56682264f9d3
dangling blob c2ad8101cfcf3d21e33c8da3f0677b5b9cc58c30
dangling blob c5d98571c464030b61978b6812fa3579c7294b99
missing tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
在查看了一些悬空的斑点后,我意识到虽然它们具有已删除文件的内容,但也有一些乱码:
slug_fieldtidtMetacBseZeZdZRS(tcreatedtownertimage(screatedsownersimage(R(R)Rtmodeltfields(((sE/home/invinciblycool/PycharmProjects/jotter_api/jotter/serializers.pyR1HsN((
R(R)R
tNonetTrueR4RtSlugRelatedFieldR3R1(((sE/home/invinciblycool/PycharmProjects/jotter_api/jotter/serializers.pyR+?s
tNoteSerializercBs3eZejdedd�Zddd��YZRS(R.R/R0R1cBseZeZdZRS(R3R2ttext(sownerscreatedstext(R(R)RR5R6(((sE/home/invinciblycool/PycharmProjects/jotter_api/jotter/serializers.pyR1Ss((R(R)RR9R8R3R1(((sE/home/invinciblycool/PycharmProjects/jotter_api/jotter/serializers.pyR:M (RRtrest_frameworkRtmodelsRRR t
ImageFieldR
我如何恢复这些文件,实际上是从乱码中恢复,我什至不确定这些文件是否是这些文件。
仅供参考,Javascript 文件似乎很干净,但其他 python 和 html 文件则不然。
我试图重现你所做的事情:
1) git add .
2) rm -r -f *
在此之后我认为你做了一个git reset
, or git reset --hard
(错误的选择:它用空索引覆盖了索引,因为你从未进行过提交)...
但正确的命令如我之前的回答所示git checkout-index -af
(但是重置后这个就没用了)
此时您正确给出了git fsck --lost-found
,我的建议相当于较低级别的命令(git cat-file...
)
所以:为什么胡言乱语?
您确定目录中只有源代码文件,而不是(例如)Python 文件的编译版本(扩展名 .pyc)?也许在 IDE 创建的某个隐藏目录中?
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)