Search code examples
gitgit-submodules

Git submodule's commit matching a tag in the main repo


After I check out a tag and do git status, it shows me:

#       modified:   submodules/bcg729 (new commits)
#       modified:   submodules/belle-sip (new commits)
#       modified:   submodules/externals/ffmpeg (new commits)

git submodule update checks out earlier commits.
But in .gitmodules there's no info about specific commits in submodules when the tag was created. How does git knows it? Simply by the commit dates?


Solution

  • No those commits are registered as a special entry in the index.

    Try a git ls-files --stage, and look for entry in mode "160000":

    git ls-files --stage | grep 160000
    

    You will see the SHA1 associated for each submodules in the grep result.

    The .gitmodules is only there to record the name and url of the submodule, not its SHA1.