Last active
April 16, 2020 12:04
-
-
Save alvarobp/d48cb6184bfd22e1d44bce870705bea1 to your computer and use it in GitHub Desktop.
Pull from all git repositories within current directory
This file contains 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
#!/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