patterngitModerate
Where is the git submodule revision actually stored?
Viewed 0 times
storedthewhererevisiongitactuallysubmodule
Problem
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?Solution
The
where `
See also this question on StackOverflow.
.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 where `
is a reference to some commit (e.g. HEAD, master, a commit SHA sum) and is a path to a submodule.
The output looks something like this:
160000 commit
where 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.
Code Snippets
git ls-tree <ref> <path>160000 commit <sha> <path>Context
StackExchange DevOps Q#5371, answer score: 10
Revisions (0)
No revisions yet.