Friday, June 13, 2014

GIT Submodules Recipes

In Git, parent project is associated with submodule project at git-commit level, NOT at git-branch level.

ParentProj at GIT-repo-Parent
ChildProj at GIT-repo-Child

Person GitAdmin setup git repo

  • parentRepo
  • childRepo

PersonA clone and add submodule

  • personA clone parentProj 
  • personA clone childProj
  • personA add childProj  to parentProj as submodule
  • personA commit submodule change (at commit 100)
  • personA push up changes 
PersonB use parentProj


  • personB clone parentProj (including childProj)
  • personB init, update submodule childProj (now childProj is at detached commit 100) 
PersonA upgrades submodule
  • personA update childProj in master
  • personA commit changes in childProj in master (at commit 120)
  • personA push up childProj changes to origin/master
PersonA update parent to use childProj's newest commits
  • personA add/commit childProj changes in parentProj (uses new childProj commit 120)
  • personA push up parentProj  
PersonB updates parentProj to pick up changes
  • PersonB pull parentProj changes (will see parentProj points to a newer ChildProj commit 120)
  • PersonB update submodule (this will sync ChildProj to the commit 120) notes: will lost local uncommitted changes in ChildProj







No comments:

Post a Comment