Can git submodule update be made to fetch tags in submodules?

Duncan Parkes picture Duncan Parkes · Sep 21, 2011 · Viewed 10.8k times · Source

I have a git repository which uses a submodule which I'd like to point at an annotated tag, but when I do git submodule update new tags don't get fetched. I can get new tags in the submodule by cd-ing into the submodule and doing a git fetch --tags there, but I'd really like to do all of this from the outside as it's scripted.

I can't find anything in the git documentation suggesting a way to get git submodule update to include tags (my git version is 1.7.3.5).

Obviously there is another possibility - to point the submodule at the commit which the tag points to rather than the tag itself, but this doesn't seem as neat.

Is there a way of getting git submodule update to include tags?

Answer

jsdalton picture jsdalton · Sep 5, 2012

Late answer here, but I'm surprised that no one mentioned git submodule foreach. This is basically the way I solved the exact problem you encountered:

git submodule foreach --recursive 'git fetch --tags'
git submodule update --recursive

--recursive flag is there to recurse into child submodules.