I really like this command to fetch a repo with submodules:
git clone git@github.com:my_user/my_repo.git --recursive
However, the submodule
As already answered
git submodule foreach --recursive git checkout master
does the job for the branch master.
But if it is a branch that is not present in all of the submodules one can use
git submodule foreach --recursive "git checkout branchname || true"
Otherwise the command will fail on the first repo not having the specified branch.