Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 1.29 KB

File metadata and controls

34 lines (25 loc) · 1.29 KB

Git Submodules - Main

Example of a product repository which uses git submodule

  • module folder pointed to a specific git hash of another git repo
  • module-dev folder pointed to dev branch of another git repo

Init and update module

Specific git commit

git submodule add git@github.com:berezhinskiy/git-submodule-module.git module
cd module
git checkout <commitid>
git commit -m 'Update module to <commitid>' module

Specific git branch

git submodule add -b dev git@github.com:berezhinskiy/git-submodule-module.git module-dev

⚠️ Potential problem with pointing to the branch name

After cloning the repo, submodules will be switched into a detached HEAD state. If you make changes in the submodule branch and commit, Git will create the commit and leave submodules with a detached HEAD.

> git status
HEAD detached at f74a7bb
nothing to commit, working tree clean

submodule.<name>.update and submodule.<name>.branch parameters in .gitmodules config can solve this potential problem.

More info is here