LinuxCommandLibrary
GitHub F-Droid Google Play Store

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
Batch-print info and content for objects on stdin
$ git cat-file --batch
copy
Batch-check type and size for objects on stdin
$ git cat-file --batch-check
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
Exit with zero status if the object exists and is valid.
--batch
Print object info and content for each object id read from stdin.
--batch-check
Print object type and size for each object id read from stdin.
--textconv
Show content as transformed by a configured textconv filter.
blob
Show blob.
commit
Show commit.
tree
Show tree.

SEE ALSO

git-show(1), git-hash-object(1), git-ls-tree(1), git-rev-parse(1), git-verify-pack(1)

Copied to clipboard
Kai

AltStyle によって変換されたページ (->オリジナル) /