git clone --recursive git@github.com:url_to/awesome_submodule.git path_to_awesome_submodule
git submodule add git@github.com:url_to/awesome_submodule.git path_to_awesome_submodule
git submodule init
… or to fetch all submodules, even if not initialized yet, and recursively in case submodules have submodules
git submodule update --init --recursive
cd path/to/module
git fetch
git checkout -q <commit-sha1>
cd -
git commit -am “Updated submodule X to: blah blah”
Status, like logs and diffs, is limited to the active repo (right now, the container), not to submodules, which are nested repos. This is often problematic (it’s super easy to miss a regression when limited to this view), so I recommend you set up a submodule-aware status once and for all:
git config status.submoduleSummary true
git config --global fetch.recurseSubmodules = on-demand # default for git 1.7.5+, but just in case
git config --global diff.submodule log # clearer container diffs when referenced submodule commits changed
git config --global status.submoduleSummary true # git status is useful again when a referenced submodule commit changed
git config --global alias.spull '!git pull && git submodule sync --recursive && git submodule update --init --recursive'
git config --global alias.spush 'push --recurse-submodules=on-demand'