16

I have a project which depends on Twitter bootstrap 2.x, however, when I add bootstrap as a submodule using the following:

git submodule add https://github.com/twbs/bootstrap.git

This brings in the latest version of bootstrap.

I would like to create a submodule for a specific tag, but haven't found a way to do that. Is this possible?

Daniel Walker
  • 6,380
  • 5
  • 22
  • 45
ColinE
  • 68,894
  • 15
  • 164
  • 232

1 Answers1

26

Once your submodule is created:

cd /path/to/yoursubmodule
git checkout yourTag
cd ..
git add yoursubmodule
git commit -m "use submoduile at tag xx"
git push

You records that way the fact you want a submodule at a certain tag.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    @onmyway133 A submodule is always referencing a specifc SHA1. You can configure the parent repo to make a submodule update after a branch HEAD, but even then, the submodule itself doesn't "track" anything: it just checkout the SHA1 the parent repo has. See http://stackoverflow.com/a/18799234/6309 – VonC Apr 13 '15 at 07:01
  • how does submodule know about that "specific SHA1" ? – onmyway133 Apr 13 '15 at 09:19
  • 1
    @onmyway133 the submodule itself does not know, the parent repo does, through a gitlink, a special entry in its index, which memorize that specific SHA1. See the links in http://stackoverflow.com/a/29327427/6309. – VonC Apr 13 '15 at 09:30