Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the pros and cons of Git submodule and Repo? [duplicate]

Tags:

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?

like image 355
binarycreations Avatar asked Jun 14 '11 09:06

binarycreations


People also ask

Are git submodules a good idea?

Git submodules may look powerful or cool upfront, but for all the reasons above it is a bad idea to share code using submodules, especially when the code changes frequently. It will be much worse when you have more and more developers working on the same repos.

Why do we need git submodule?

Git submodules allow you to keep a git repository as a subdirectory of another git repository. Git submodules are simply a reference to another repository at a particular snapshot in time. Git submodules enable a Git repository to incorporate and track version history of external code.

What does git pull -- recurse submodules do?

If you pass --recurse-submodules to the git clone command, it will automatically initialize and update each submodule in the repository, including nested submodules if any of the submodules in the repository have submodules themselves.

What are git Subtrees?

A Git subtree is a replica of a Git repository that has been dragged into the main repository. A Git submodule is a reference to a particular commit in a different repository. Git subtrees, which were first introduced in Git 1.7. 11, help you make a copy of any repo into a subdirectory of another.


2 Answers

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.

Hope this helps

like image 81
Adam Dymitruk Avatar answered Oct 21 '22 10:10

Adam Dymitruk


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.

like image 30
user1133275 Avatar answered Oct 21 '22 10:10

user1133275