Maintaining submodules in a Git repository
I'm learning new Git tricks thanks to Damien and want to make sure I don't forget any of them, so I'm introducing a new Git tag here on the blog to start writing these down.
I'm working on a project with the team in Paris for the week, and the structure of the project is such that we maintain a main Git repository that pulls in Drupal and a variety of contributed modules using git submodules. To build the full project locally, I first clone our main repository and then issue git submodule init / update commands to get the proper versions of our submodules.
Now, I'm still learning the ropes with Git terminology and repository management, but from what I understand, a submodule folder points to the URL of the repository and a precise commit. It won't automatically track a branch, so when the remote repository has new commits or you make new commits in your submodule repositories, you have to tell the main repository something has changed.
First you would change directories into the submodule and either pull in the new commits or perhaps make your changes, commit them, and push them upstream. Then you would change back into the main repository directory and perform a git add on the submodule directory. Committing this will update the main repository to point to the new current commit in the submodule directory. Pushing this upstream will ensure that everyone else on the project can pull the change and use git submodule update to pull the new commits into their local submodule directories.
Pretty straightforward I suppose?