Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 312
Sami Issa Avatar asked Aug 23 '17 08:08

Sami Issa


1 Answers

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 [email protected]:Sami/my-library.git. 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 [email protected]:Sami/my-library.git 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.

like image 132
andrei_zaitcev Avatar answered Sep 29 '22 08:09

andrei_zaitcev