Last Updated: February 25, 2016
·
392
· pasierb

Execute git command on multiple repos

Save this script in folder where you keep your repos as git_all_repos, make executable and enjoy.

Usage: git_all_repos pull

#!/bin/bash

shift $(($OPTIND - 1))

# Replace manually specified repos with this to run script on all directories
#
#PWD=`pwd`
#DIRS=`ls -l $PWD | egrep '^d' | awk '{print $9}'`


# Specify on which repos run script
#
declare -a DIRS=(admin-portal admin-portal-api client-manager client-manager-api commons product-ingest product-ingest-api product-ingest-worker product-manager search-client search-manager search-manager-api store-presentation)


for DIR in ${DIRS[@]}
do

#Execute command
#
OUT=`cd $DIR && git ${*}`

#Pretty  print
#
echo -e ""
echo -e "executing in: $DIR"
echo $OUT
echo "-------------------------------"

done