There are many reasons to combine outside projects with your own. A submodule is simply a project that forms a part of your own Git repository but also exists independently in its own source control repository. This chapter discusses why developers create submodules and how Git attempts to deal with them.
Earlier in this book, we worked with a repository named public_html that we imagine contains your website. If your website relies on an AJAX library such as Prototype or jQuery, then you’ll need to have a copy of that library somewhere inside public_html. Not only that: you’d like to be able to update that library automatically, see what has changed when you do, and maybe even contribute changes back to the authors. Or perhaps, as Git allows and encourages, you want to make changes and not contribute them back but still be able to update your repository to their latest version.
Git does make all these things possible. But here’s the bad news: Git’s initial support for submodules was unapologetically awful, for the simple reason that none of the Git developers had a need for them. At the time that this book is being written, the situation has only recently started to improve.
In the beginning, there were only two major projects that used Git—Git itself and the Linux Kernel. These projects have two important things in common: they were both originally written by Linus Torvalds, and they both have virtually no dependencies on any outside project. Where ...