rlandster
rlandster

Reputation: 7825

Git command to list SHA1 hashes for all tree objects

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.

Upvotes: 4

Views: 566

Answers (2)

jthill
jthill

Reputation: 60255

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

Upvotes: 2

palimpsestor
palimpsestor

Reputation: 1069

You can find all of the objects accessible from the HEAD pointer

git ls-tree -r -t HEAD

so you can filter to find just the tree objects using sed or awk, for example,

git ls-tree -r -t HEAD | awk '$2 == "tree" { print $0 }'

Upvotes: 2

Related Questions