pts
pts

Reputation: 87221

What is the tree hash of a specific commit hash?

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?

Upvotes: 9

Views: 1785

Answers (3)

reddot
reddot

Reputation: 985

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

git rev-parse ${COMMITID}:

Upvotes: 1

Klas Mellbourn
Klas Mellbourn

Reputation: 44377

git log -1 --pretty="%T" $COMMITID 

Upvotes: 12

Stefan Näwe
Stefan Näwe

Reputation: 3104

git rev-parse $COMMITID^{tree}

Upvotes: 20

Related Questions