We are have 2 rails projects for which /models are common for both of the projects and so we maintained a separate repo by using submodules concept.
Now in project1 I created a branch rails3_upgrade
from master for my submodules ie, in app/models.
how can I checkout to that branch in project2 models from master?
I tried get fetch --all
and git remote -v
and some other options but couldn't see the branch I created.
Googled but couldn't find. Can anyone tell me how can I do this?
A branch created in a parent repo project1 won't be visible by other repos (submodules or project2)
You can create that branch in a submodule of Project1, and see it in the same submodule in project2
cd /path/to/project1/submodule1
git checkout -b newBranch
git push -u origin newBranch
cd /path/to/project2/submodule1
git fetch
git checkout newBranch --track origin/newBranch
As usual, is you make any modification in a submodule, don't forget to add and commit in the parent repo as well.
Creating a branch in a submodule does not mean the submodule will always checkout the latest of that branch though.
For that, see " Git submodules: Specify a branch/tag " I wrote before.
And for the submodule to update itself to the latest of that branch, you would need a
git submodule update --recursive
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.