Commands like git log dress the data up for you. git cat-file shows the object as git stores it, which is a nice way to understand what a commit is.
git cat-file -p HEAD
-p pretty-prints the object. For a commit it looks like this:
tree ff78f29bb25e2d545e6c538927700c1ef5403b99
parent 7a6d5c030ab31d3fedacc56e2a15d33fc09b76c8
author Alice <[email protected]> 1796051349 +0100
committer Alice <[email protected]> 1796051349 +0100
Fix login redirect
That’s all a commit is: a pointer to a tree, one or more parents, two names with timestamps, and the message. Run git cat-file -p on the tree hash and you get the list of files and folders with their own hashes. Do it on one of those and you see the file content.
I find it handy for debugging too. You can see whether a commit has one parent or two, check the raw timestamps and time zone, or spot a signature header. git cat-file -t tells you the type of an object when you only have a hash and don’t know what it is.
This is a plumbing command, meant for reading. It doesn’t change anything, so it’s safe to poke around with. The output format of -p is for people though; scripts should use the more explicit forms like git cat-file commit HEAD.
Further reading: git-cat-file documentation, Pro Git: Git Objects