I would like to tag all of the submodules of my project. I tried to do that with:
git submodule foreach git tag tagName
... but it appears to just return with no errors, having done nothing.
Edit: Here are the results of my attempt:
Can someone tell me how to properly tag all submodules?
Note: this a very similar question to this post, but the answer for that one suggested to rely on the submodule refs in the super-project. I, however, would actually like a tag in the submodule's repo.
First, make sure your submodule folder has a content:
git submodule update --init --recursive
Then, simply do:
git submodule foreach git tag -l
You should see, for each submodule, tagName
.
Meaning your previous command did indeed tag those submodules.
I would recommend making an annotated tag though, not a lightweight one:
git submodule foreach git tag -m "tagName" tagName
That means you can push that tag from each submodule, preferably using the --follow-tags
option from git push
.
git submodule foreach git push origin --follow-tags
If you just tag at the parent repo level, that will include the submodule gitlink, that is their SHA1. That could be enough in your case.
If git submodule foreach
is too slow, try a shell script, for testing:
#!/bin/bash
git submodule update --init --recursive
for submodule in $(git config --file .gitmodules --get-regexp path | awk '{ print $2 }'); do
echo "Tagging submodule $submodule"
cd $submodule
git tag -a v1.0 -m "Version 1.0 tag"
git push origin v1.0
cd -
done