Commit 8d9bcc10 authored by Sadman Kazi's avatar Sadman Kazi 🎸

Add submodules basics

parent 9677a13c
......@@ -27,6 +27,7 @@ Table of Contents:
### Git
* [Configuring using `git config`](git/
* [Pushing to multiple remote repos](git/
* [Submodules basics](git/
* [Useful aliases: `push --force-with-lease`](git/
### Linux
Submodules basics
`git` submodules are especially useful when we require the use of code from
different repositories, examples include third-party libraries and frameworks.
> Submodules allow you to keep a Git repository as a subdirectory of another
Git repository. This lets you clone another repository into your project and
keep your commits separate. - [git-scm](
### Add submodules to an existing project
git submodule add GIT_REPO_URL
By default, submodules will add the subproject into a directory named the same
as the repository.
### The `.gitmodules` file
The above command automatically adds the file to the root directory of the
original repository. The file lists all the submodules added to the project:
This file can be manually created and edited.
### Working with projects with submodules
Two ways to do it, first is to clone the original repo and running a couple of
commands to download the submodules:
git submodule init
git submodule update
The second way is by passing the `recursive` flag to the `git clone` command:
git clone --recursive ORIGINAL_GIT_REPO_URL
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment