meta data for this page
  •  

https://andrey.nering.com.br/2016/git-submodules-vs-subtrees/

submodules

Submodule is only a link to commit ref in another repo.

Add

Adding submodule:

git submodule add <repository> [<relative_local_path>]

Init

After cloning master repo with submodules:

git submodule init
git submodule update

alternatively repo can be clonned with

git clone --recursive <url>
git submodule update --init --recursive
git fetch --recurse-submodules

Remove

Removing submodule:

  • git submodule deinit lib/lib_to_be_deleted
  • remove entry in .gitmodules
  • stage .gitmodules
  • ? remove entry in .git/config
  • remove dir: git rm –cached lib/lib_to_be_deleted
  • remove module content: rm -rf .git/modules/lib_to_be_deleted