git plumbing: cat-file

Digging into git a bit more.

cat-file¬†is part of git’s plumbing. Here’s what it shows. If we use:

git cat-file -p head

to show the contents of the latest commit object.

Note: https://stackoverflow.com/questions/2304087/what-is-head-in-git

Then to see details of the tree¬†object you’d use:

git cat-file -p <sha1 of tree>

which shows the contents of the working directory.

And to see the contents of the file itself you’d use the sha1 of the blob. E.g.

git cat-file -p <sha1 of blob>

Note that the blob is the entire contents of the file NOT just a diff.

 

Leave a Reply

Your email address will not be published. Required fields are marked *