Git Submodule Tips
I’ve recently started using git submodules as a way of implementing a continual integration strategy within plugin based architectures. Here are a few tips I’ve found for making this easier.
Managing Submodules
Always remember to tell git about any changes you make to a submodule. You’ll want to (1) push your changes to the submodule and (2) commit and push the branch you were on when you made the change to the submodule. If you do not do these two things any one else pulling from the repository will not get the updated submodule.
Sometimes it is useful to have a nested submodule. This is when you have submodules within other submodules. Dealing with this can become a bit cumbersome, especially after an initial cloning of a project. Fortunately, git allows us to keep the structure up to date with a single command.
git submodule update --init --recursive
Removing a git submodule.
To remove you’ll need to remove the reference from git’s cache.
git rm --cached path/to/submodule
Once the submodule has been removed from git’s cache, you can remove the code as needed.