1

I'm new with Git submodules.

I have the following structure in my project:

src/main/com/feature1
src/main/com/feature2
src/main/com/feature3
src/main/com/commonFeature

I have the same structure for the tests, but under the following package:

src/test/com/feature1 ...

As the package "commonFeature" is something that I want to reuse for other projects, I would like to create a Git submodule for it. I'm thinking about the following options to reorganize my packages structure:

src/main/com/commonFeature/main/
src/main/com/commonFeature/test/

or

src/commonFeature/main
src/commonFeature/test

Then I would keep my other packages project as before under:

src/main/com/feature1 ....

What would be the best way?

halfer
  • 19,824
  • 17
  • 99
  • 186
user2992476
  • 1,536
  • 2
  • 17
  • 29

1 Answers1

0

A few considerations on your question:

src/main/com/commonFeature/main/
src/main/com/commonFeature/test/

Is not consistent with the description of your initial repository, so you'll probably have to fix a lot of broken links.

src/commonFeature/main
src/commonFeature/test

This as well is not consistent, and without any additional knowledge on /main/com/ it is an alternative just as good as the first one.

Seen that in both cases you'll have to fix a lot of links, you should approach the problem thinking in a different way.

You cannot add a git submodule in the root of your git repository. This forces you to move all the common libs to a new folder. If that is the case, just think of your new folder like this:

/._
  |_ /.git
  |_ /main
  |_ /test

You'll have to add it somewhere in your current, where depends on the meaning of /src, /main, /com. Anyway you look at it you'll have to fix broken links.

An alternative to preserve your current tree and have another repository would be to clone two repositories in the same directory. This is tricky, and is a workaround to the limitation posed by SubModules.

Daemon Painter
  • 3,208
  • 3
  • 29
  • 44