Shell script example of using GetOpts with Git Submodule.
#!/bin/sh
REMOTE=origin
BRANCH=dev
showHelp()
{
cat << EOF
Pull in the latest changes from remote branch.
Usage: $(basename $0) [OPTIONS]
OPTIONS:
-h Show this help message
-b Branch name (default: $BRANCH)
-r Remote alias (default: $REMOTE)
EOF
}
while getopts "hr:b:" option; do
case $option in
r)
REMOTE=$OPTARG
;;
b)
BRANCH=$OPTARG
;;
h)
showHelp
exit
;;
esac
done
git pull $REMOTE $BRANCH
git submodule foreach git pull $REMOTE $BRANCH