git-cat-file
Display Git object content
TLDR
Get the [s]ize of the HEAD commit in bytes
Get the [t]ype (blob, tree, commit, tag) of a given Git object
Pretty-[p]rint the contents of a given Git object based on its type
SYNOPSIS
git cat-file [-t
PARAMETERS
-t
Show the object type (blob, tree, commit, tag).
-s
Show the object size.
-e
Exit with zero status if
-p
Pretty-print the object's content.
--batch
Read objects from stdin, one per line.
--batch-check[=
Read objects from stdin and show info.
--follow-symlinks
Follow symbolic links when examining tree entries.
--textconv
Apply textconv filter.
--filters
Apply object filters.
--path=
Use
--obj-name
Show the object name instead of the content.
--allow-unknown-type
Allow accessing objects of unknown types.
--buffer-output
Buffer the output.
--in-place
Operate on the given objects directly, instead of writing to standard output.
The Git object (blob, tree, commit, tag) to inspect.
DESCRIPTION
The `git cat-file` command provides a Swiss-army knife for accessing the contents of Git repository objects. It allows you to view object data (blobs, trees, commits, tags) in different formats, verify their type, and even extract their size. Think of it as a low-level tool for directly interacting with the Git object database. It's primarily intended for scripting and internal Git operations rather than everyday user interaction. This command is useful for understanding the internal structure of a Git repository and for debugging purposes. It can also be leveraged to build other Git tools or scripts that require direct access to Git object data. You can use it to examine the contents of files stored in your repository, browse the directory structure represented by trees, and inspect the metadata associated with commits and tags. The versatility of `git cat-file` makes it a valuable tool for Git experts and developers.
OBJECT SPECIFICATION
Most Git tools pretty-print the information stored in the Git database in a human-readable way, but sometimes you need to peek inside and see the raw data. This command allows you to do just that, enabling direct examination of Git objects.
EXAMPLES
Example 1: Display the type of a commit object:
git cat-file -t HEAD
Example 2: Display the content of a blob object:
git cat-file -p
Example 3: Check if an object exists:
git cat-file -e
SEE ALSO
git-hash-object(1), git-show(1), git-ls-tree(1), git-rev-parse(1)