更新时间:2021-08-30 05:31:12
您可以
git fsck --full --cache --dangling
并查找dangling blob
条目-其中之一应该是丢失的文件.
and look for dangling blob
entries - one of them should be your lost file.
您可以尝试grep(为确保确定,在这里我们选择更大的一组未引用对象):
You can try to grep (here we select a bigger set of unreferenced object, just to be sure):
git fsck --unreachable --no-reflogs --full 2>/dev/null | awk '$2 == "blob" {print $3}' | xargs git grep -a your-search-string
它将打印找到的斑点的SHA-1以及匹配的行.
It will print SHA-1 of the found blob along with the matched line.
有了哈希后,请使用git show <hash>
来查看文件.
Once you have the hash, use git show <hash>
to see the file.