A quick "how-to" submodule
When working on a software project, you sometimes find yourself in a situation where you need to use another project as a part of your project. This other project can be anything, from another project you are developing to a third-party library. You want to keep projects separate, even though you need to use one project for the other. Git has a mechanism for this kind of project dependency, called submodules. The basic idea is that you can clone another Git repository into your project as a subdirectory, but keep the commits from the two repositories separate, as shown in the following diagram:
Getting ready
We'll start by cloning an example repository to be used as the super project:
$ git clone https://github.com/PacktPublishing/Git-Version-Control-Cookbook-Second-Edition_Super.git
$ cd Git-Version-Control-Cookbook-Second-Edition_Super
How to do it...
- We'll add a subproject,
lib_a
, to the super project as a Git submodule:
$ git submodule add https://github.com/PacktPublishing...