LinuxCommandLibrary

git-cat-file

Display content or metadata of repository objects

TLDR

Show object type

$ git cat-file -t [object]
copy
Show object size
$ git cat-file -s [object]
copy
Show object content
$ git cat-file -p [object]
copy
Show blob content
$ git cat-file blob [hash]
copy
Show commit content
$ git cat-file commit [hash]
copy
Show tree content
$ git cat-file tree [hash]
copy

SYNOPSIS

git cat-file [options] object

DESCRIPTION

git cat-file provides direct access to Git's object database, allowing inspection of blobs, trees, commits, and tags. This low-level plumbing command reveals the internal structure of Git's content-addressable storage system.
The command operates on object hashes (SHA-1 or SHA-256) and can display object type, size, or pretty-printed content. It's essential for debugging repository corruption, understanding Git internals, and forensic analysis of repository history.
Common use cases include examining specific versions of files without checking them out, inspecting tree structures to understand directory layouts at specific commits, and validating object integrity. The -p flag pretty-prints objects in human-readable format, while -t and -s provide metadata without full content extraction.

PARAMETERS

-t

Show object type.
-s
Show object size.
-p
Pretty-print content.
-e
Check if object exists.
blob
Show blob.
commit
Show commit.
tree
Show tree.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community