4

Using the command git show-ref --tags I can see all the tags and the SHA1 hashes for all these tags.

I would like a similar command for trees: a command to output all the SHA1 hashes for all the tree objects, but for nothing else.

4

2 回答 2

2

您可以找到从 HEAD 指针访问的所有对象

git ls-tree -r -t HEAD

sed因此您可以使用or进行过滤以仅查找树对象awk,例如,

git ls-tree -r -t HEAD | awk '$2 == "tree" { print $0 }'
于 2016-01-09T05:51:54.610 回答
2
git rev-list --all --objects     |     # everything reachable, with path
cut -d' ' -f1                    |     # don't want the path
git cat-file --batch-check       |     # append type and size
awk '$2=="tree"'                       # just the trees
于 2016-01-09T06:15:18.587 回答