Adding a Submodule with Git

Page

Sometimes you have Drupal in a git repository and you want to use a single submodule from Luggage. For example, you might have a site on which you want only the People feature.

Here is how to add a submodule to your git repository.

Conceptually

In English, you are telling your git repository that contains the code for your website where the git submodule is, so that when you type

git submodule update --init

it will automatically pull in the submodule.

Moving On

First, you add the submodule by hand:

cd /path/to/my/drupal/site
git submodule add git@github.com:isubit/luggage_people.git sites/all/modules/luggage/luggage_people

This has updated the .gitmodules file in your repository. So now you should commit the changed .gitmodules file to your repository, so next time you clone the repository it will contain the pointer to the submodule git add .gitmodules sites/all/modules/luggage/luggage_people.

commit -m 'Adding people as a submodule'
git push

 

Category: