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
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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 https://github.com/dvaske/super.git
$ 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://github.com/dvaske/lib_a.git lib_a
    Cloning into 'lib_a'...
    remote: Counting objects: 18, done.
    remote: Compressing...