Search code examples
gitgit-submodules

Create a git submodule from a specific repo hash or tag


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?


Solution

  • 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.