Skip to content

Instantly share code, notes, and snippets.

@mslinn
Last active March 11, 2024 17:09
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mslinn/3151915 to your computer and use it in GitHub Desktop.
Save mslinn/3151915 to your computer and use it in GitHub Desktop.
Bash Script to Update all Git Directories Below Specified Directories
#!/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
@david-bakin-sl
Copy link

This is definitely the way to use find to search for repos, TY!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment