Question

I want to organize all my java, C and Android projects with Git.

I have several folders:

something_like_gdlib
example_library1
example_library2
...
example_project1
example_project2
...

In each of those projects I use some of those libraries. But if I update a library, I want all projects to get the changes for that library.

Usually I work alone on those projects and I just want to have a change history.

Now I want to work together with another programmer, that should get access to only one project and the corresponding libraries.

How should I set up git? I heard of subtrees or submodules? Or is there a better solution?

Was it helpful?

Solution

Submodules or subtrees could indeed be a solution.

On the other hand you could keep the repos totally independent from a git point of view, and publish your libraries.

Eg: Assuming you're working with Maven in Java, when you want to upgrade example_library1 in example_project1 you could:

  • Build a new version of the library (and tag the corresponding commit)
  • Put this binary either in a local or shared maven repository
  • Update the version of the library in the pom.xml of your project

An advantage of this approach would be that there are no need to do anything complicated with Git

Drawbacks would be:

  • It may be cumbersome if you want to upgrade in your application every time you commit in your library
  • If you don't already have a "package architecture", you may need to set it up first
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top