Home > Back-end >  How to get the commit IDs from all the tags in a submodule?
How to get the commit IDs from all the tags in a submodule?

Time:01-05

I'm using the following command to get the tags in each of the submodules:

git submodule foreach git tag --sort=-taggerdate -l 

But I'm not sure how to also get the commit IDs for each tag listed.

Any help would be appreciated.

UPDATE:

Submodule commit ID:

enter image description here

Tag commit ID, selected the matching one:

enter image description here

CodePudding user response:

Well, it seems you want to list tags that point to commits in submodules where those commits in submodules correspond to a commit in the superproject. The simplest way is to checkout the commit (or a branch, or a tag) in the superproject, update submodules to checkout saved commits (every commit in the superproject stores commits to checkout in its submodules) and list tags in every submodule that point to submodule's HEAD:

git checkout --recurse-submodules master # or tag, or SHA1 in the superproject
git submodule foreach --recursive git tag --points-at=HEAD --format="%(refname:lstrip=2) %(objectname:short)"

git tag has an option --format="string". For the list of field names see git help for-each-ref.

CodePudding user response:

If commit date order is okay, rather than the tagger date:

git submodule foreach git log --no-walk --tags HEAD --oneline
  • Related