submodules
git submodules are entire projects that are incorporated into another project. These submodules maintain their own version history. The most important point to understand is that when working with a submodule, you are only doing the following:
- telling the master project what to call the submodule (a directory name)
- telling the master project where to pull this submodule project from (a repo location)
- telling the master project which SHA-1 hash (revision number) of this submodule will be used in the master project
adding a submodule
git submodule add /path/to/submodule.git path/for/submodule/in/your/project (adds a folder for the submodule, and creates .gitmodules at the root of your project) git submodule init (adds the submodule reference info from .gitmodules to your .git/config) git submodule update (checks out the submodule)
removing a submodule
- Delete the relevant line from the .gitmodules file.
- Delete the relevant section from .git/config.
- Run git rm –cached path_to_submodule (no trailing slash).
- Commit and delete the now untracked submodule files.
Source: http://stackoverflow.com/questions/1260748/how-do-i-remove-a-git-submodule
cloning a project that has submodules
The easiest way to clone a project with submodules is to use the --recursive flag, which initializes and checks out all submodules.
git clone --recursive /path/to/repo.git or git clone --recursive /path/to/repo.git myproject