An issue I am having with my project is in one branch (BRANCH1), I added 2 submodules (MOD1, MOD2). Now BRANCH1 has been put on hold.
Now that I am working on BRANCH2, I would like only the submodules (the rest of the changes are not ready yet). How would I add MOD1 and MOD2 to my current branch?
If there was a single commit on
BRANCH1whose sole effect was adding one (or both) submodules, then you cangit cherry-pickthat commit (or those commits, if you added the submodules in separate commits) ontoBRANCH2. If the submodule additions were done as part of a bigger commit that you don’t want the rest of, you can usegit cherry-pick --no-commit, then clean out the changes you don’t want before committing. Or you could always just run the appropriategit submodule addcommands onBRANCH2(which may or may not result in a freshcloneof the submodules – I can’t say I’ve ever run into that situation, so I don’t know for sure…).