1

Small question about git submodule.

Assume I have a projectA, and it have a submodule maybe called moduleA.

Then I create a tag in projectA, tagA, then I may have some new commits for projectA or moduleA also, and then I want to go back to the tagA, using git checkout tagA.

The problem is projectA go back to tagA, but moduleA not.

Do you know how can make this?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Tim
  • 2,006
  • 2
  • 18
  • 25

1 Answers1

2

Simply update your submodule one you go back to tagA in the parent repo:

git submodule update

Update the registered submodules, i.e. clone missing submodules and checkout the commit specified in the index of the containing repository.

As usual, the result repo of the submodule will be in a detached HEAD mode.
Note that projectA (with a checkout of a tag) will also be in a detached HEAD mode.

The tag reference the parent rpeo content, including the gitlink ( a special entry in the index of the parent repo) which points to a specific SHA1 of the submodule.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Note to self: And that was my **12000th answer** on Stack Overflow (in 77 months), less than 5 months after the [11000th answer](http://stackoverflow.com/a/25821796/6309). Before that, [10000th answer](http://stackoverflow.com/a/23909654/6309), [9000th answer](http://stackoverflow.com/a/20683667/6309), [8000th answer](http://stackoverflow.com/a/17569094/6309), [7000th answer](http://stackoverflow.com/a/14274272/6309), [6000th answer](http://stackoverflow.com/a/11644343/6309), [5000th answer](http://stackoverflow.com/a/7917396/6309), [4000th answer](http://stackoverflow.com/a/4953561/6309), ... – VonC Feb 09 '15 at 17:13