Last active
March 11, 2024 17:09
-
-
Save mslinn/3151915 to your computer and use it in GitHub Desktop.
Bash Script to Update all Git Directories Below Specified Directories
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 | |
# Update all git directories below specified directories | |
# Skips directories that contain a file called .ignore | |
# See https://stackoverflow.com/a/61207488/553865 | |
HIGHLIGHT="\e[01;34m" | |
NORMAL='\e[00m' | |
export PATH=${PATH/':./:'/:} | |
export PATH=${PATH/':./bin:'/:} | |
#echo "$PATH" | |
DIRS="$( find "$@" -type d \( -execdir test -e {}/.ignore \; -prune \) -o \( -execdir test -d {}/.git \; -prune -print \) )" | |
echo -e "${HIGHLIGHT}Scanning ${PWD}${NORMAL}" | |
for d in $DIRS; do | |
cd "$d" > /dev/null | |
echo -e "\n${HIGHLIGHT}Updating `pwd`$NORMAL" | |
git pull | |
cd - > /dev/null | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is definitely the way to use
find
to search for repos, TY!