Skip to content

Instantly share code, notes, and snippets.

@meoso
Last active April 24, 2017 12:49
Show Gist options
  • Save meoso/eb7abd64c06db1fe712c24e71906502f to your computer and use it in GitHub Desktop.
Save meoso/eb7abd64c06db1fe712c24e71906502f to your computer and use it in GitHub Desktop.
"git pull" all sub .gits for a given path
#!/bin/bash
#######################################################
# purpose : "git pull" all sub .gits for a given path
# author : njd
# created : 2015-03-05
# modified : 2017-04-21
# usage : ./pull-all-gits.sh [path]
#######################################################
ESC="\033"
NORMAL="$ESC[m"
DULL=0
BRIGHT=1
FG_CYAN=36
CYAN="$ESC[${DULL};${FG_CYAN}m"
if [ "$1" == "" ]
then
FS=$(pwd)
else
FS=$1
fi
read -r -p "pull ALL gits under $FS? [y/N] " response
case "$response" in
y) find "$FS" -type d -name ".git" -exec echo -e "\n${CYAN}{}${NORMAL}" \; -exec git -C '{}/..' pull \; -exec echo "" \;
;;
*) echo "aborted"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment