How to recover files from missing tree and dangling blobs?

后端 未结 2 1962
抹茶落季
抹茶落季 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:20

    1) rm -r -f . should abort without effect probably you did rm -r -f * and it does not delete the .git directory

    2) this is confirmed by the fact that the command git fsck --lost-found did not abort

    in this situation (deletion of just the working directory) the correct command to recover as much as possible is:

    git checkout-index -af : this copies the version currently on the index (the one that you just put with git add .) to the working directory

提交回复
热议问题