Mike D
Mike D

Reputation: 4946

Git: Add Submodule from Another Branch

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?

Upvotes: 1

Views: 161

Answers (1)

twalberg
twalberg

Reputation: 62369

If there was a single commit on BRANCH1 whose sole effect was adding one (or both) submodules, then you can git cherry-pick that commit (or those commits, if you added the submodules in separate commits) onto BRANCH2. If the submodule additions were done as part of a bigger commit that you don't want the rest of, you can use git cherry-pick --no-commit, then clean out the changes you don't want before committing. Or you could always just run the appropriate git submodule add commands on BRANCH2 (which may or may not result in a fresh clone of the submodules - I can't say I've ever run into that situation, so I don't know for sure...).

Upvotes: 1

Related Questions