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?
If you want to check for new work in a submodule, you can go into the directory and run git fetch and git merge the upstream branch to update the local code. Now if you go back into the main project and run git diff --submodule you can see that the submodule was updated and get a list of commits that were added to it.
It is stored in Git's object database directly. The tree object for the directory where the submodule lives will have an entry for the submodule's commit (this is the so-called "gitlink").
Pulling with submodules. Once you have set up the submodules you can update the repository with fetch/pull like you would normally do. To pull everything including the submodules, use the --recurse-submodules and the --remote parameter in the git pull command .
First, as commented by brookbot
, git submodule status
will print the SHA-1 of the currently checked out commit for each submodule, along with the submodule path and the output of git describe for the SHA-1.
See my other answer below.
You can start with git ls-files -s
(as in this answer)
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)
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.
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".
Open your shell in the required project folder and then type the following git
command:
git submodule
The resulting output would look like:
<module commit> <module-path> (<module-branch)
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With