Skip to content

Instantly share code, notes, and snippets.

@alvarobp
Last active April 16, 2020 12:04
Show Gist options
  • Save alvarobp/d48cb6184bfd22e1d44bce870705bea1 to your computer and use it in GitHub Desktop.
Save alvarobp/d48cb6184bfd22e1d44bce870705bea1 to your computer and use it in GitHub Desktop.
Pull from all git repositories within current directory
#!/usr/bin/env bash
function filter_directories () {
grep -ve '^\(.\|./IgnoreA\|./IgnoreB\)$'
}
failed=""
for directory in $(find . -maxdepth 1 -type d | filter_directories | sort); do
pushd $directory &> /dev/null
if [ ! -d .git ]; then
continue
fi
echo "Pulling $directory ..."
git fetch -q --all && git checkout -q master && git pull -q &> /dev/null
if [ $? -ne 0 ]; then
failed="$failed $directory"
fi
popd &> /dev/null
done
if [[ ! -z $failed ]]; then
echo
echo "Failed to pull: $failed"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment