Created
February 4, 2014 20:49
-
-
Save gregkrsak/8812057 to your computer and use it in GitHub Desktop.
A small Bash script to update git submodules.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# update-submodules | |
# | |
# Updates all submodules of a git project. | |
# by Greg Krsak <[email protected]>, Feb. 4, 2014 | |
# | |
read -r -d '' USAGE << EOF | |
Usage: update-submodules [<options>] | |
Options: | |
-b BRANCH use the provided branch | |
-r update sub-submodules | |
-h show this message, then exit\n | |
EOF | |
OPTIONS='b:rh' | |
BRANCH='master' | |
while getopts $OPTIONS option | |
do | |
case $option in | |
b) BRANCH=$OPTARG | |
;; | |
r) RECURSIVE=true | |
;; | |
h) printf "$USAGE" && exit 2 | |
;; | |
*) printf "$USAGE" && exit 1 | |
;; | |
esac | |
done | |
shift $(($OPTIND - 1)) | |
git submodule foreach git pull origin $BRANCH | |
if [ "$RECURSIVE" == true ]; then | |
git submodule foreach git submodule foreach git pull origin $BRANCH | |
fi | |
# End of update-submodules | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment