Skip to content

Instantly share code, notes, and snippets.

@abtris
Created May 17, 2022 07:47
Show Gist options
  • Save abtris/b24c870405cf1f4b6634b9fe328da892 to your computer and use it in GitHub Desktop.
Save abtris/b24c870405cf1f4b6634b9fe328da892 to your computer and use it in GitHub Desktop.
Update git source code in all directories
for name in */ ; do
if [ -d "$name" ] && [ ! -L "$name" ]; then
cd $name
if [ -d ".git" ]; then
BRANCH=`git branch --no-color | grep -e "^*" | tr -d ' *'`
if [ "$BRANCH" == "master" ] || [ "$BRANCH" == "main" ]; then
if git remote | grep origin > /dev/null; then
printf 'Update source in directory: %s\n' "$name"
git pull
fi
fi
fi
cd ..
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment