Skip to content

Instantly share code, notes, and snippets.

@todgru
Last active October 13, 2015 01:08
Show Gist options
  • Save todgru/4115343 to your computer and use it in GitHub Desktop.
Save todgru/4115343 to your computer and use it in GitHub Desktop.
Git submodule

#Submodules

Here is how we do it at Our Office


When you clone your working repos (api, app, www), you'll have an empty Modules directory. The working repo will contain a pointer to the hash of the last Modules repo committed. All that needs to be done from your working repo directory is:

$ git subumodule init

then:

$ git submodule update

All of the modules' files will be pulled down into the Modules directory.

Making Changes to the Modules

You can make changes directly in the modules subdirectory of your repo. Commit and push those changes as you normally would. cd back out into the root of your working repo.

  • A git status shows Modules (new commits) in the modules repo.
  • Need to git add . to add the changed module sha as the new version to keep.
  • then git commit -a -m"message"
  • git push origin master

If you think something in your modules is wrong, no problem. Note: Since git submodule update didn't solve the problem, its likely the last commit for that working repo committed an incorrect submodule. Check your work. Re-commit the working repo with the correct module.

Also, note one can delete Modules directory: rm -rf Modules. Then execute the command git submodule update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment