Recover staged but not committed files after 'git rm -rf'

孤者浪人 提交于 2019-11-27 20:40:15

(update) Use git fsck instead, it is a builtin command for retrieving files you have once added to git repository.

git fsck --lost-found --unreachable

after the command processing, retrieved files will be placed at .git/lost-found/other, with file name of a sha256 hash. Although the original name is still lost, the content will be back.


You can find your files in your .git/objects directory.

Suppose there is a .git/objects/2f/ae996f8f8f9298b41ba4fdbac3d62014f9579e object, you can execute

git cat-file -p 2fae996

to get the content of your lost file.

But I'm sorry, I have no idea about reconstructing your directory or doing this automatically.

Udan

have you tried :

git reset --hard

?

Hope that works :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!