How to recover files from missing tree and dangling blobs?

后端 未结 2 1937
抹茶落季
抹茶落季 2021-01-27 23:22

After git add . I ran git rm -r -f .,and all my local files were deleted accidentally. After recovering them with git fsck --lost-found I

2条回答
  •  情话喂你
    2021-01-28 00:13

    I tried to reproduce what you did:

    1) git add .

    2) rm -r -f *

    after this I think that you made a git reset, or git reset --hard (wrong choice: it overwrote the index with an empty one because you never did a commit)...

    but the correct command were as indicated in my previous answer git checkout-index -af (but this is useless after the reset)

    at this point you gave correctly the git fsck --lost-found, my suggestion was equivalent with lower level commands (git cat-file...)

    so: why gibberish?

    Are you sure that in the directory there was only source code files and not (for example) compiled versions of the python files (extension .pyc)? Perhaps in some hidden directory created by a IDE?

提交回复
热议问题