To find out what exact hash any revision expression resolves to, use git rev-parse
, whose name hints at its full purpose, as a complete options-and-args parsing toolkit for Git-extending commands.
See git revisions
for all the ways you can specify things that resolve to Git id's.
There are a lot of them, because while Git's underlying structure is (all but literally incredibly) simple, the number of things that can (and development work demands) be done with it is endless, and dizzying, and there are a lot of conveniences to make supporting specific workflows more, well, convenient.
If somecommit
refers to a commit or a tag, somecommit:
refers to the (tagged) commit's tree, as does somecommit^{tree}
for those occasions where the bare :
might get missed by inspection.
A following :
is generally the "get me to a tree" syntax, (leading :
is "get me to the index").
To list a tree, use git ls-tree
. A quick structural overview is e.g. git ls-tree -rd @:
To list the index, git ls-files
, which has a lot of handy options; it's basically the swiss-army knife of index-aware file listing, or perhaps the entire swiss army, maybe that's just me being a teensy bit hyperbolic.
So if somecommit:path/to/file
is whatever's listed in that commit at that path, :path/to/file
is whatever's listed in your index at that path. There's lots more, see that link.
And since somecommit:
names some commit's tree, git rev-parse somecommit:
will show you its id; :path/to/file
names the index entry for that path, git rev-parse :path/to/file
will show you the¹ content id in that entry.
¹ For in-flight merges Git keeps three entries, one for each of the base, ours, theirs content, so you and your tools, including Git's own automerge, can examine the differences, eventually adding the correct result and updating the main index entry. Git somewhat inscrutably calls these "stages", and you can refer to them explicitly with :1:path/to/file
and similarly for 2 and 3. The main entry is stage 0.