25

It just so happens that we share a library between 3 different mobile platforms. There is much debate within the office on what is the best tool to use to manage this library. Repo (Android) from what I read is a tool built on top of Git used for managing the hundreds of Git repositories used for Android, whilst Git submodule is already part of Git.

We would ideally like to have this library in a separate repository and be able to simply integrate it within each of the different mobile applications.

What are the pros and cons of using git submodule or Repo as approaches for managing a shared library that is used between various platforms?

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
binarycreations
  • 3,091
  • 6
  • 32
  • 38
  • erm... do it as you like it? git submodule is straightforward and doesn't require additional tools. If you have external users, just provide 'distributable' packages (tarball?) and let the users decide how they wish to manage the dependency – sehe Jun 14 '11 at 10:08
  • 1
    very good overview what submodules are: http://speirs.org/blog/2009/5/11/understanding-git-submodules.html – reto Jun 14 '11 at 12:37
  • By library, do you mean "sources of a library", or the binary itself of the library to share? Git submodules would manage sources, but a binary is better stored elsewhere outside of a Git repo. – VonC Jun 14 '11 at 14:51
  • Sorry I should of mentioned that, I mean sources of a library. – binarycreations Jun 15 '11 at 15:21

2 Answers2

7

Git submodules is built for this. We've been using submodules for libraries and more. The progit.org/book has a great chapter about submodules and shows an example of upgrading a library from one version to another.

funnydman
  • 9,083
  • 4
  • 40
  • 55
Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
  • 1
    Here's a link for the chapter mentioned by Adam: http://git-scm.com/book/en/v2/Git-Tools-Submodules – Rhubbarb May 14 '15 at 16:55
2

The main difference is that Git submodule tracks and Repo does not. The result is that checking out an exact commit of an old version is only possible with git.

The second most important difference is that Git is popular and Repo is not. The result is that finding solutions for Git is faster.

Maybe the only reason Repo exists is that Git submodule did not exist at the time of Repo's creation.

user1133275
  • 2,642
  • 27
  • 31
  • 1
    "The main difference is that Git submodule tracks and Repo does not". Repo allows to create and maintain the snapshot manifests making it more flexible than submodule solution. In addition, multiple manifests could be created for different project configurations/ECU or testing stages for example. Not sure it could be easily done with submodules. Correct me if I'm wrong. – vladisld Jan 17 '21 at 12:08