Interview Prep/Git & GitHub/Git internals: objects, refs and the index

What are the four object types in Git's object database?

BeginnerConceptGit internals: objects, refs and the index
Answer

Blob, tree, commit and annotated tag. A blob stores file contents only (no name, no mode). A tree maps names and modes to blobs and sub-trees, so it represents a directory. A commit points to one tree, zero or more parent commits, and carries author, committer and message. An annotated tag points to another object and carries a tagger and message.

git cat-file -t HEAD        # commit
git cat-file -p HEAD^{tree} # list the root tree
All Git & GitHub questions Roadmap: Git & GitHub

More on Git internals: objects, refs and the index