Yes. Well, sort of. In git, files are stored internally as something called a blob. Blobs are identified by a SHA-1 in a manner very similar to that of a commit. You can find the SHA-1 of any file based on its contents using git hash-object
:
git hash-object -- <path>
If you want to find the hash for a file at a specific revision, git hash-object
also accepts file contents from standard input:
git show <revision>:<path> | git hash-object --stdin
Then you can retrieve the text of that file with git show
:
git show <blob sha-1>
Going from a blob id to a path and revision is a lot harder. Blobs can be stored at multiple paths across multiple revisions, so there's really no single definitive path/revision combination that a blob is stored at. It's possible to find a list of which revisions and paths contain a given blob (see Which commit has this blob?) but that's farily complicated and doesn't really sound like what you want anyway.
If you really want a textual representation of a file at a specific revision, then your original idea of (<path>, <revision>)
seems perfectly reasonable to me. <revision>:<path>
would also work well, as that's the format accepted by git show
(as demonstrated in the example above).