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?

The .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>

where <ref> is a reference to some commit (e.g. HEAD, master, a commit SHA sum) and <path> is a path to a submodule.

The output looks something like this:

160000 commit <sha> <path>

where <sha> is the commit in the submodule. The number in front has the following meaning, according to the Git book:

Notice the 160000 mode 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.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.