Reputation: 197
I want to place submodule_A at master and place submodule_B at new_branch.
But, on the master, I can see both submodule_A and submodule_B in the repo.
How to separate the two submodules at the right branch?
Thanks for reply!!!
NOTE:I use the following command before.
git submodule add -b new_branch submodule_B;
But submodule_B is still existing on master branch.
When I checkout master, the git displays
warning: unable to rmdir submodule_B
When I checkout new_branch, the git displays
warning: unable to rmdir submodule_A
==============================================
For Example
https://github.com/ShawnHuang/.vim/tree/master/bundle
All plugins is submodules at my repo.
On branch master, I want to use ultisnips.
And, on branch junk/snipmate, I want to use snipmate.
I can separate the two submodules at differnt branches at github.
But I can't do it at local.
Upvotes: 1
Views: 2638
Reputation: 66339
If you create 2 branches, with 2 different submodules:
$ git init
$ git checkout -b one
$ git submodule add [email protected]/a/repo.git one
$ git checkout -b two
$ git submodule add [email protected]/another/repo.git two
When not part of the current branch they are simply treated as untracked files. I.e. Unless you yourself delete the unreferenced submodules when switching branches they will be present in all branches:
$ git checkout master
$ ls
one two
$ git checkout one
$ ls
one two
$ git checkout two
$ ls
one two
A simple ish way to do what you ask is to just move the submodule folder whenever it's not relevant:
$ git checkout one
$ mv two .two
$ git checkout two
$ mv .two two
$ mv one .one
Upvotes: 1
Reputation: 1613
create new bracnh
git branch submodule-b
checkout that module
git checkout submodule-b
add all sub module file and commit them
git add .
git commit -m 'Submodule new branch created'
to go main/submodule A branch
git checkout submodule-a
Upvotes: 1