Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 602
ColinE Avatar asked Sep 12 '13 05:09

ColinE


People also ask

How do I create a submodule from an existing repo?

In order to add a Git submodule, use the “git submodule add” command and specify the URL of the Git remote repository to be included as a submodule. When adding a Git submodule, your submodule will be staged. As a consequence, you will need to commit your submodule by using the “git commit” command.

How do you initialize a submodule?

If you already cloned the project and forgot --recurse-submodules , you can combine the git submodule init and git submodule update steps by running git submodule update --init . To also initialize, fetch and checkout any nested submodules, you can use the foolproof git submodule update --init --recursive .


1 Answers

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.

like image 195
VonC Avatar answered Oct 02 '22 18:10

VonC