Skip to content

Instantly share code, notes, and snippets.

@velocityzen velocityzen/puller
Created Oct 22, 2013

Embed
What would you like to do?
git pull in all sub directories. good for refreshing big projects.
#!/bin/bash
current_dir=`pwd`/
dir=$current_dir
usage="Usage : `basename $0` [-d dir] [-h] args\nWhere args are directories that you don't whant to pull"
while getopts hd: opt; do
case $opt in
d)
if [ ! -d $OPTARG ] ; then
echo "$OPTARG is not a directory" >&2
exit 1
fi
dir=$OPTARG
;;
h)
echo -e $usage
exit 0
;;
\?)
echo -e $usage >&2
exit 1
;;
esac
done
shift `expr $OPTIND - 1`
for PARAM;
do
if [ ! -d $dir$PARAM/ ] ; then
echo "$dir$PARAM/ is not a directory" >&2
exit 1
fi
done
for f in `ls $dir`
do
real_f=$dir$f/
if [ -d $real_f ] ; then
count=0
for PARAM;
do
if [ $real_f = $dir$PARAM/ ] ; then
count=1
break
fi
done
if [ $count -eq 0 -a -e $real_f/.git/ ] ; then
cd $real_f
echo -e "\x1B[34mPulling $real_f \x1B[39m"
echo -e "`git pull`\n"
fi
fi
done
cd $current_dir
@adammenges

This comment has been minimized.

Copy link

adammenges commented Jun 16, 2016

Hey this is pretty nifty, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.