I want get the current commit id of the specified submodule. I thought when I cd into submodule directory and run git rev-parse HEAD i get this after I noticed this is a superproject current id. Tried git submodule status | grep <submodule_name> also but its to slow to me. Any idea how to get this information little bit faster?
git rev-parse HEAD
git submodule status | grep <submodule_name>
You can start with git ls-files -s (as in this answer)
git ls-files -s
cd /path/to/parent/repo git ls-files -s yourSubmodule
Note the absence of a trailing '/' after yourSubmodule (which is the root folder of the checked out submodule)
/
yourSubmodule
That will give the mode and sha1 associated with the gitlink (special entry in the index of the parent repo)
160000 4d77d23305c5623356955ef9f908f4ec76780ba9 0 yourSubmodule
(The '0' is for the stage number)
Alternatives:
cd /path/to/repo/parentFolder/of/submodule git ls-tree @ yourSubmodule git rev-parse @:./yourSubmodule
The rev-parse only returns the submodule SHA1.
rev-parse
As commented by heloman, you can also find the SHA1 with:
git rev-parse HEAD:path-to-your-sub-module
See more in "How to see which commit a git submodule points at".
2.1m questions
2.1m answers
60 comments
57.0k users