is added as a subdirectory of another Git repository.! ✤ The contents of the subdirectory are not tracked by the containing repository. ! ✤ It is checked out at a particular commit, not any particular branch.! ✤ The submodule communicates with it’s own upstream repository independently of the containing repository.
to the URL of the submodule and the directory which contains it. Shared with all repositories! ✤ The .git/conﬁg ﬁle has a reference to the URL of the submodule and directory which contains it. Local to the current repository.! ✤ The .git/modules folder has the actual git repository for the submodule! ✤ The sha of the commit is stored in the repository under the tree of the directory. Just like any other object sha.
model! ✤ Just the contents of the ﬁle, not the name, or the mode! ✤ Compressed, and named after it’s SHA-1 hash! ✤ If the contents of several ﬁles are the same, the blobs are the same.! ✤ Referred to by the 40 character hash, though 4-7 characters are usually enough! ✤ git cat-ﬁle -p <sha> is a handy command
path = Externals/AFNetworking! ! url = https://github.com/Abizern/AFNetworking.git [submodule "Externals/AFNetworking"]! ! url = https://github.com/Abizern/AFNetworking.git • The index is updated, but the changes are not checked in.! • You can change the URL of the submodule locally.! • You can change the commit that the submodule points to.
update! ✤ Check your submodules are up to date with git submodule status! ✤ ALWAYS push changes to your submodule before commiting to the enclosing repository.! ✤ git rm --cached ﬁles if you are extracting code to a submodule.! ✤ Use your own clone if you are adding Open Source! ✤ Use http:// URLs instead of git@ or git://
use as a submodule.! ✤ Different branches can have different versions of submodules, or even different submodules.! ✤ Changes can be pushed up from the submodule to a shared repository! ✤ Less of a hurdle for pushing code back to Open Source Projects.