I understand how to use git submodule to reference a specific commit in another repo, but where is that reference actually stored? It doesn't seem to be in
.gitmodules as plain text?
.gitmodules file just records the path and remote URL to the submodule repository. The commit itself is stored in the tree object. You can query it like this:
git ls-tree <ref> <path>
<ref> is a reference to some commit (e.g.
master, a commit SHA sum) and
<path> is a path to a submodule.
The output looks something like this:
160000 commit <sha> <path>
<sha> is the commit in the submodule. The number in front has the following meaning, according to the Git book:
160000mode for the
DbConnector(submodule path of the example used in the book) entry. That is a special mode in Git that basically means you’re recording a commit as a directory entry rather than a subdirectory or a file.
See also this question on StackOverflow.