I thought I had it all worked out with this new project and thought that git submodules are the way to to develop and deploy my application.
Set up my git repo (Drupal) and initialized it with the 7.12 tag of Drupal. Made my own branch. Then added the modules that are needed under sites/all/modules/contrib with git submodule add --branch 7.x git://path/to/drupal/module sites/all/modules/contrib/module
and then I thought, by pushing my repo to github, I would be able to simply pull it and then it would pull all the submodules into the deployment path. However, all my modules are not pulled, even if I do: git submodule foreach git pull or git submodule init followed by git submodule update
Turns out, I was wrong. Do I now need to redo everything in another way? If yes, please tell me how, if not, great, please let me know.
Once you have set up the submodules you can update the repository with fetch/pull like you would normally do. To pull everything including the submodules, use the --recurse-submodules and the --remote parameter in the git pull command .
This is because of some major drawbacks around git submodules, such as being locked to a specific version of the outer repo, the lacking of effective merge management, and the general notion that the Git repository itself doesn't really know it's now a multi-module repository.
With Git 2.34, if the repository is cloned with the --recurse-submodules , a simple git pull will recurse into submodules.
Git submodules may look powerful or cool upfront, but for all the reasons above it is a bad idea to share code using submodules, especially when the code changes frequently. It will be much worse when you have more and more developers working on the same repos.
You forked the Drupal repo? Does it already have sub modules added in .gitmodules
? If so you only needed to clone their branch and perform
git submodule init git submodule update
You don't need to re-add their own sub modules to the repo.
Now if you want to add additional submodules you have to perform git submodule init; git submodule update
every time you clone the repo. It will not automatically get the submodules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With