-
-
Save Pelirrojo/eb1316f0e7592da02a6dc9d954b8dd38 to your computer and use it in GitHub Desktop.
Update all git repositories under a base 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
#!/bin/bash | |
clear | |
CUR_DIR=$(pwd) | |
TOTAL=0 | |
OK=0 | |
KO=0 | |
# Let the person running the script know what's going on. | |
echo -e "\n\033[34mP******************************************************\033[0m" | |
echo -e "\033[34m* Pulling in latest changes for all repositories... *\033[0m" | |
echo -e "\033[34mP******************************************************\033[0m" | |
# Find all git repositories and update it to the master latest revision | |
for i in $(find . -name ".git" | cut -c 3-); do | |
echo ""; | |
echo -e "\033[33m"+$i+"\033[0m"; | |
# We have to go to the .git parent directory to call the pull command | |
cd "$i"; | |
cd ..; | |
# finally pull | |
git fetch; | |
git pull origin master; | |
if [ $? -ne 0 ]; then | |
KO=$((KO+1)) | |
else | |
OK=$((OK+1)) | |
fi | |
# lets get back to the CUR_DIR | |
cd $CUR_DIR | |
TOTAL=$((TOTAL+1)) | |
done | |
echo -e "\n\033[33m${TOTAL} repos scanned\033[0m" | |
echo -e "\033[32m${OK} repos updated ok\033[0m" | |
echo -e "\033[31m${KO} repos not right updated\033[0m" | |
echo -e "\n\033[34m**********************************\033[0m" | |
echo -e "\033[34m* Git Recursive Update Complete! *\033[0m" | |
echo -e "\033[34m**********************************\033[0m" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment