
Sometimes we require to have external libraries or we have some dependencies on external libraries in order to make our application work in this scenario git submodules comes very handy which creates a mirror folder in our code repository.
It’s not necessary that we always require external libraries as submodule, we can also have our own micro projects as git submodule in repository.
Syntax to add git submodule
git submodule add git@github.com:drupal/drupal.git drupal
Syntax to update git submodule
git submodule update --init --recursive
git submodule foreach --recursive git fetch
git submodule foreach git merge origin master
Above command will update the submodules code from their parent repository.
Syntax to remove git submodule
git submodule deinit <path_to_submodule>
git rm <path_to_submodule>
git commit -m "Removed git submodule"
rm -rf .git/modules/<path_to_submodule>