Answers: <p>The <code>.gitmodules</code> 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:</p>
  
  <pre><code>git ls-tree &lt;ref&gt; &lt;path&gt;
  </code></pre>
  
  <p>where <code>&lt;ref&gt;</code> is a reference to some commit (e.g. <code>HEAD</code>, <code>master</code>, a commit SHA sum) and <code>&lt;path&gt;</code> is a path to a submodule.</p>
  
  <p>The output looks something like this:</p>
  
  <pre><code>160000 commit &lt;sha&gt; &lt;path&gt;
  </code></pre>
  
  <p>where <code>&lt;sha&gt;</code> is the commit in the submodule. The number in front has the following meaning, according to <a href="https://git-scm.com/book/en/v2/Git-Tools-Submodules" rel="noreferrer">the Git book</a>:</p>
  
  <blockquote>
    <p>Notice the <code>160000</code> mode for the <code>DbConnector</code> <em>(submodule path of the example used in the book)</em> 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.</p>
  </blockquote>
  
  <p>See also <a href="https://stackoverflow.com/q/5033441/1347968">this question on StackOverflow</a>.</p>
  
Answers: CC BY-SA 4.0
Answers: 2018-11-08T18:46:51.777Z
Answers: 2018-11-08T18:46:51.777Z
Answers: siegi
Body: <p>I understand how to use <a href="https://git-scm.com/book/en/v2/Git-Tools-Submodules" rel="noreferrer">git submodule</a> to reference a specific commit in another repo, but where is that reference actually stored? It doesn't seem to be in <code>.gitmodules</code> as plain text?</p>
  
Tags: <git><cicd>
Title: Where is the git submodule revision actually stored?
UserDisplayName: Gaius
ThreadText: # Where is the git submodule revision actually stored?
  
  (Asked by: username_0 on 2018-11-07)
  
  I understand how to use [git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules) 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?
  
  **Tags:** git, cicd
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-11-08. Score: 11 | Accepted answer
  
  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](https://git-scm.com/book/en/v2/Git-Tools-Submodules):
  
  > 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](https://stackoverflow.com/q/5033441/1347968).
  
  
  ---
  
  