dors
dors

Reputation: 5892

How to use git submodule with a 3rd party library?

I want to add a 3rd party lib on github as a git submodule for a project I'm working on.

Since this is a library that can change, and those changes are out of my hands, I was wondering what is the best practice for using it as a submodule.

The options I had in mind are:

  1. Forking the lib and using that as a sub module to ensure no changes harm my project.
  2. Using a specific version's branch/tag (is that possible) as a submodule

Is one of these options the recommended way to go? Is there a better way aside these options?

Upvotes: 1

Views: 2572

Answers (1)

gturri
gturri

Reputation: 14629

  • If this library owner publish packages, it might be easier to use your language manager: you'll just have to update the version number you want to use when a new package is available.

  • Otherwise, using submodules (or subtree) might be an option. As stated in the comments, you'll still get to choose the commit of the library you want to use, and you'll update whenever you choose to.

As an example, this project used successively both solutions: it started with submodules, and eventually referenced this library as a maven package.

Note that using submodules, you'll end up cloning the library in your workspace, so there's not really any point in wondering if you need to fork the library.

Upvotes: 1

Related Questions