Skip to content

Instantly share code, notes, and snippets.

@MatiasDuhalde
Created September 14, 2021 01:16
Show Gist options
  • Save MatiasDuhalde/c4a4f2c1915ed8efc7c5a59876960e81 to your computer and use it in GitHub Desktop.
Save MatiasDuhalde/c4a4f2c1915ed8efc7c5a59876960e81 to your computer and use it in GitHub Desktop.
Bash script for pulling all repos in current directory
# FIND ALL NESTED REPOS
echo "Looking for repositories in" `pwd`
# CHANGE -mindepth TO 1 TO ALSO PULL REPO IN SAME DIRECTORY AS SCRIPT
REPOSITORIES=`find -mindepth 2 -type d -name '.git' -printf '%h\n' | sed 's/^.\{1\}//'`
echo "Found:"
echo "$REPOSITORIES"
# GET SCRIPT DIR
BASEDIR=$(pwd)
cd "$BASEDIR"
echo $'\nPreparing to pull found repositories...'
# PULL EACH NESTED REPO
for DIR in $REPOSITORIES
do
cd ${BASEDIR}${DIR}
echo $'Pulling' `pwd`$'...\n'
git pull # print everything after the final "/"
echo ''
done
echo $'\nAll done!\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment