Reputation: 1983
I have a repo with multiple submodules. I have a commit's hash but do not know to which submodule it belongs, how I could find it's exact submodule?
Upvotes: 1
Views: 226
Reputation: 26074
git submodule status
will give you a list of the currently checked out commit hash id for each submodule. You can parse that and find out the name of the submodule corresponding to the commit hash:
$ commit_id="14f4e19f1c"
$ git submodule status | awk -v commit_id="$commit_id" '$0 ~ commit_id {print $2}'
(this assumes that you are working with the latest commit hash from that submodule)
Upvotes: 2