Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple urls of git submodule - per remote submodules

Tags:

I have git repository with two remotes (github and bitbucket). Inside I have submodule, that points accordingly to another github/bitbucket repo. But in the definition of submodule is url, that is hardcoded. Can I have two of them? Or one per remote? So that my main repo on github points to submodule on github. And my main repo on Bitbucket points to submodule on bitbucket?

[submodule "programs/mgr-nancy-demo"]     path = programs/mgr-nancy-demo     url = [email protected]:wedkarz/mgr-nancy-demo.git 
like image 462
Fishman Avatar asked Aug 31 '15 18:08

Fishman


1 Answers

It seems you can use relative URLs for submodules. From git help submodules:

COMMANDS

add

[...]

<repository> is the URL of the new submodule’s origin repository. This may be either an absolute URL, or (if it begins with ./ or ../), the location relative to the superproject’s origin repository

So, if you follow the same naming convention in both sites (ie, github.com/you/parent-project, bitbucket.org/you/parent-project, github.com/you/child-project and bitbucket.org/you/child-project), you should be able to set the submodule like this:

[submodule "programs/mgr-nancy-demo"]     path = programs/mgr-nancy-demo     url = ../mgr-nancy-demo.git 

Test it - YMMV!

like image 153
mgarciaisaia Avatar answered Oct 28 '22 00:10

mgarciaisaia