Run "git pull" in all subdirectories that contain a git repository
#!/usr/bin/env bash
# Pull all respositories in all direct subdirectories
#
# @param ... - directories to pull (optional)
pull_all()
{
local D
# don't quote @ because it will prevent globbing
# shellcheck disable=SC2068
for D in ${@:-*}
do
D=${D%/}
[ -d "$D/.git" ] || continue
echo "pulling $D"
(cd "$D" && git pull origin master) || [ "$FORCE" ] || {
read -r -p 'Continue? (y/n) ' -n 1
echo
[ "$REPLY" != 'y' ] && break
}
done
}
if [ "${BASH_SOURCE[0]}" == "$0" ]
then
pull_all "$@"
fi