I wrote the below script to push all the changes in the workspace, both in the submodules and the superproject. However, it sounds a little odd that, it is this complex to do what I want. Is there any better way, that I'm missing?
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
exit
fi
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "${SCRIPT_DIR}/../submodule1"
git status
git add -A
git commit -m "$1"
git push origin master
cd "${SCRIPT_DIR}/../submodule2"
git status
git add -A
git commit -m "$1"
git push origin master
cd "${SCRIPT_DIR}/../submodule3"
git status
git add -A
git commit -m "$1"
git push origin master
printf "\n\nUpdating Super Project\n\n"
cd ..
git status
git add -A
git commit -m "All Submodules Updated - $1"
git push origin master
git1.7.11 ([ANNOUNCE] Git 1.7.11.rc1) mentions:
"git push --recurse-submodules" learned to optionally look into the histories of submodules bound to the superproject and push them out.
So you can use:
git push --recurse-submodules=on-demand