Sami Issa Sami Issa - 6 months ago 37
Git Question

Use different git repo for different modules

In my Android application I've created a new library module. Now I have this structure:

enter image description here

Right now I have under version control on Bitbucket whole project less datingcorelib. I would like to use a different repo to this library module.

It's possible to use two different repos on the same project?

Thanks in advance.


Answer Source

Yes, it is possible. You're looking for a thing called submodule.

However, it may be tricky to use such a submodule within a project as it will have its own structure. So you also need to include the right gradle project from that submodule.

Let's say you pushed your library project somewhere. Let it be We also assume that it has the common structure for Android library project, i.e. it has a root build.gradle file and a subfolder datingcorelib with actual source code. This is what we need to include into the app.

You need to delete datingcorelib from your app's project. Then add the library as a submodule:

git submodule add libraries/datingcorelib

After that open settings.gradle file of your app's project and add a new line there:

project(':datingcorelib').projectDir = new File("$rootDir/libraries/datingcorelib/datingcorelib")

Sync the project. Now you should be able to use the code from another repository.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download