Skip to content

Instantly share code, notes, and snippets.

@riyadhalnur
Last active September 7, 2018 02:49
Show Gist options
  • Save riyadhalnur/8d01f8ac30f743d0b9efa6cf50b941be to your computer and use it in GitHub Desktop.
Save riyadhalnur/8d01f8ac30f743d0b9efa6cf50b941be to your computer and use it in GitHub Desktop.
Recurses a parent directory to do git pulls inside each repo/sub folder
#!/bin/bash
trap 'echo "Wait for the script to finish"' SIGINT SIGTERM EXIT
# Recurses a directory to do git pulls in each repo folder
BASEDIR=/Users/test/go/src/github.com
for dir in "$BASEDIR"/*
do
if [[ -d "$dir" ]]; then
cd "$dir"
if echo "$(git branch)" | grep "* master"; then
echo "Pulling in $dir..."
git pull
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment