Created
September 14, 2021 01:16
-
-
Save MatiasDuhalde/c4a4f2c1915ed8efc7c5a59876960e81 to your computer and use it in GitHub Desktop.
Bash script for pulling all repos in current directory
This file contains hidden or 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
# 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