git cat-file -t <hash>

Display the type of a Git object specified by `<hash>`.

This command is useful for exploring a repository's internals by querying Git's object database and printing the type (commit, tree, blob, or tag) of the object identified by the given hash.

It uses cat-file to access internal objects and the -t flag (short for --type) instructs Git to output only the object's type rather than its content, while <hash> specifies the SHA-1 or SHA-256 identifier of the object.

Related variations include git cat-file -s <hash> to display object size and git cat-file -p <hash> to pretty-print object content; you can also use --type instead of -t or batch-process multiple objects with git cat-file --batch.

Examples:

  • git cat-file -t 9fceb02
  • git cat-file -t HEAD~1
  • git cat-file -t 4b825dc642cb6eb9a06f

Welcome to GitExamples!

Sign in to enable bookmarking, reminders, progress-tracking and more...