Use git cat-file
.
To see the type of an object, use git cat-file -t revspec
, where revspec
is any valid revision specifier (see gitrevisions). For instance:
$ git cat-file -t master
commit
To see the contents of an object, use git cat-file -p revspec
. If the revspec
identifies a "blob" (a file), this gives you the raw contents of the file. Note that no filters are applied.
(If it identifies a commit, tag, or tree, you get a printable representation of that.)
(You can only apply filters to paths, not raw object-IDs. Turning a blob ID into a set of paths that specify that blob is nontrivial, but not impossible unless the blob is unreferenced; however, there may be multiple paths referring to a single blob, a la Unix/Linux hard links.)