Search code examples
gitgit-submodules

Where to find the expected git submodule hash


Where does git store the hash of a submodule that would be checked out if I did this?

git submodule update --init --recursive

I want to write a program that prints the expected hash and the current hash (as well as the submodule paths and the corresponding branch names) for all submodules for which the two hashes don't match.


Solution

  • git rev-parse revision:path/to/submodule
    

    outputs the hash. revision can be anything pointing to a commit for which you want to learn the hash of the submodule: it can be HEAD, branch like master, a tag, a commit hash.

    path/to/submodule is the path from repository root.