Book Image

Git Version Control Cookbook

By : Aske Olsson, Rasmus Voss
Book Image

Git Version Control Cookbook

By: Aske Olsson, Rasmus Voss

Overview of this book

Table of Contents (19 chapters)
Git Version Control Cookbook
About the Authors
About the Reviewers

A quick submodule how-to

When developing a software project, you sometimes find yourself in a situation where you need to use another project as a subpart of your project. This other project can be anything from the another project you are developing to a third-party library. You want to keep the projects separate even though you need to use one project from 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
$ cd super

How to do it...

  1. We'll add a subproject, lib_a, to the super project as a Git submodule:

    $ git submodule add git:// lib_a
    Cloning into 'lib_a'...
    remote: Counting objects: 18, done.
    remote: Compressing...