: $ git push
+*** Updating all submodules to follow upstream branches
+
+Submodules are usually in the *detached HEAD* state, as you would get
+by running
+
+ : $ git checkout <SHA>
+
+The foreach command checks out a particular local branch in the
+submodule repository, and pulls any changes from that branch's default
+upstream (=branch.name.remote= and =branch.name.merge= in
+=.git/modules/modname/config=). The name of the branch to check out
+is extracted from =.gitmodules=, so you'll want to manually specify
+your intended branch (e.g. after adding a new submodule):
+
+ : $ git submodule add -b xyz git://example.com/abc.git somedir
+ : $ git config -f .gitmodules submodule.somedir.branch xyz
+
+Once you've done that for each of your submodules, you can (since Git
+version 1.7.2, commit f030c96d) run
+
+ : $ git submodule foreach 'git checkout $(git config --file $toplevel/.gitmodules submodule.$name.branch) && git pull'
+
*** Removing submodules
From the [[http://git.or.cz/gitwiki/GitSubmoduleTutorial][Git Wiki]]