Search code examples
gitbashgit-submodules

How do I get the SHA of HEAD in a specific git submodule?


My project has multiple git submodules. I need the SHA commit of one submodule in particular to present in the app.

git submodule foreach accepts a command like rev-parse, but it loops over all submodules, which I don't want. git submodule status MySubmoduleFolder gives too much output.


Solution

  • Found my own solution. Unlike cut, awk will ignore the first space.

    git submodule status MySubmoduleFolder | awk '{print $1;}'