Git: Sub-Modules

From Glitchdata
Jump to navigation Jump to search

Sub Modules are essential in larger projects. It allows for clear division of design, code, testing, and work. This is a crucial feature for good code management.


  • Set up a sub-module
  • Refreshing code from a sub-module

Steps: Setup a sub-module

  1. Command line
  2. Create .gitmodules file
  3. Edit .gitmodules file
[submodule "lib/zend"]
  url = git@myserver:zend.git
  path = lib/zend

Populate Sub-Module code

  • git submodule init
    • This pull down setting. No code updated
  • git submodule update
    • Pulls down code

Steps: Updating code from Sub-Module

  • git submodule -q foreach git pull -q origin master

Deleting a Sub-Modules

  • Git has no command line entry to remove a sub-modules
  • Removal has to be done manually


Related Git Commands