获取.git/objects/文件夹中所有blob的平面列表

gr8qqesn  于 2022-12-02  发布在  Git
关注(0)|答案(2)|浏览(212)

In the .git/objects/ folder there are many folders with files within such as ab/cde... . I understand that these are actually blobs abcde...
Is there a way to obtain a flat file listing of all blobs under .git/objects/ with no / being used a delimitor between ab and cde in the example above? For e.g.

abcde....
ab812....
74axs...

I tried

/.git/objects$ du -a .

This does list recursively all folders and files within the /objects/ folder but the blobs are not listed since the command lists the folder followed by the filename (as the OS recognizes them, as opposed to git). Furthermore, the du command does not provide a flat listing in a single column -- it provides the output in two columns with a numeric entry (disk usage) in the first column.

kq0g1dla

kq0g1dla1#

我认为你应该从这里开始(git version 2.37.2):

git rev-list --all --objects --filter=object:type=blob

这样做的好处是,不仅可以检查 * unpacked * 对象所在的目录,还可以检查已经打包的对象(不再位于该目录中)。

vlju58qv

vlju58qv2#

如果您在.git/objects/文件夹中

试试这个
find . -type f | sed -e 's/.git\/objects\///' | sed -e 's/\///'
sed -e需要sed脚本,这意味着查找/替换模式。
's/.git\/objects\///'找到.git/objects/,并将其替换为''''是空的。因此,sed命令删除模式。
模式中的\是转义字符。
第一个sed命令结束后,结果将是(在linux中)。

61/87c3f3d6c61c1a6ea475afb64265b83e73ec26

要删除引用目录标志的/
sed -e 's/\///'

如果您在包含.git的目录中

find .git/objects/ -type f | sed -e 's/.git\/objects\///' | sed -e 's/\///'
试试这个。

相关问题