Links
- See also: subtree
- Manpage
- gitmodules
submodule.<name>.update = checkout | rebase | merge
submodule.<name>.url
can begin with a./
or../
to specify a location relative to the superproject’s origin repository.
- gitmodules
- http://progit.org/book/ch6-6.html
- Submodules are considered troublesome.
- SO: git submodule tracking latest
- Vogella's tutorial
- Tutorial
- Alternatives
Snippets
Ref: http://www.vogella.com/articles/Git/article.html#submodules
# When tracking commits: git submodule add master URL [path] # If there are updates to this submodule that have been comitted # upstream to this superproject, get them this way. git pull --recurse-submodules # update the superproject. gets new SHAs for submodules. git submodule init # In case more submodules were added or never init'd git submodule update --recursive git submodule status # Update a submodule and commit the change to the superproject. cd submodule_directory # Now get to the SHA you want. Typically, that might be: git checkout master git pull cd .. # back to superproject directory git add submodule_directory # record the new SHA git commit -m "submodule updated" git push # Another way is to track branches # # Providing --branch to git submodule add records the branch it in # .gitmodules and makes it track that branch. # Ref: https://github.com/git/git/commit/b928922727d6691a3bdc28160f93f25712c565f6 git submodule add --branch master URL [path] # Update the submodule to the latest on the tracked branch git submodule update --remote # If you want the HEAD for that branch but not fetch from the remote # repo for the submodule, use git submodule update --remote --no-fetch