git -file -p ':从.git/对象上随机对象上的“致命的:不是一个有效的对象名称”。

时间:2022-06-01 17:01:16

I want to learn more about the inner workings of git so I ran these commands:

我想更多地了解git的内部工作原理,所以我运行这些命令:

cd .git/objects/62

ls
00cb2f01089db22aca24675272a16712e89747
0ee798881329430bfef6c558be7b14c1f0676f
1087f408e2f2bd782d53a1211a7418fee4f6a7
a6a71f3bd5a3af882f3f0ec4fad4c672055746
f95e69f344b52c5038d922260189475626e69a

git cat-file -p 00cb2f01089db22aca24675272a16712e89747

and got the following error:

并得到以下错误:

fatal: Not a valid object name 00cb2f01089db22aca24675272a16712e89747

Why did I get it?

我为什么得到它?

I tried like 10 times (for different files from different directories inside .git/objects) and got the same error.

我尝试了10次(对于不同的文件从不同的目录在.git/对象),并得到相同的错误。

How can I view the actual content of the files (be it a blob, tree or commit)?

如何查看文件的实际内容(是blob、tree还是commit)?

1 个解决方案

#1


15  

You don't have to cd into the .git object store, but you have to provide the full sha1 hash:

您不需要将cd放入.git对象存储中,但是必须提供完整的sha1散列:

git cat-file -p 621087f408e2f2bd782d53a1211a7418fee4f6a7

Git stores its objects in .git/objects, distributed across 256 folders to keep the size of the directory down. The first two charactors of each hash are used as directory name, the remaining 38 chars are used as filename.

Git将其对象存储在. Git /对象中,分布在256个文件夹中,以保持目录的大小。每个散列的前两个字符用作目录名,其余的38个字符用作文件名。

#1


15  

You don't have to cd into the .git object store, but you have to provide the full sha1 hash:

您不需要将cd放入.git对象存储中,但是必须提供完整的sha1散列:

git cat-file -p 621087f408e2f2bd782d53a1211a7418fee4f6a7

Git stores its objects in .git/objects, distributed across 256 folders to keep the size of the directory down. The first two charactors of each hash are used as directory name, the remaining 38 chars are used as filename.

Git将其对象存储在. Git /对象中,分布在256个文件夹中,以保持目录的大小。每个散列的前两个字符用作目录名,其余的38个字符用作文件名。