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.

2
  • What do you need this for? Commented May 9, 2013 at 23:18
  • Just exploring git objects for a better understanding of how git works. Commented May 9, 2013 at 23:37

2 Answers 2

2

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 }'
Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.