Add submodule to project

# git submodule add <submodule project URL>

Clone project with submodules

Method 1: Step by step

# git clone <project URL> 
# git submodule init    # add submodule record to .git/config (which is recorded in .gitmodule)
# git submodule update  # based on submodule record in .git/config, clone the submodule project and checkout to specific commit (the commit is maintained internally in git)

Method 2: Shorter

# git clone <project URL> 
# git submodule update --init --recursive

Method 3: One step

# git clone --recurse-submodules <project URL>

Pulling in submodule upstream changes

Method 1: manually pull, one submodule each time

# cd <submodule dir>
# git pull origin <branch>

Method 2: pull all submodules

# git submodule update --remote [submodule]

This command will by default update to latest master branch for each/specified submodule(s). If you want to change the branch, run:

# git config -f .gitmodules submodule.<submodule project name>.branch <branch name>

(NOTE: If you leave off the -f .gitmodules it will only make the change for you, but it probably makes more sense to track that information with the repository so everyone else does as well)

Tips: run git submodule update to revert.