9

I need a shell command-line which puts the tree hash corresponding to a specific commit hash. I know that git cat-file commit $COMMITID | grep ^tree can do it, but I have to filter the output of that. Is there any command which prints only the hash?

3 Answers 3

20
git rev-parse $COMMITID^{tree}
12
git log -1 --pretty="%T" $COMMITID 
1

You could rev-parse top-level directory for a commit with a traling colon :

git rev-parse ${COMMITID}:

Not the answer you're looking for? Browse other questions tagged or ask your own question.