Skip to content

Instantly share code, notes, and snippets.

@selfup
Last active August 22, 2019 04:21
Show Gist options
  • Save selfup/0caa1cdfeae55d2ac38b5b16d6942c15 to your computer and use it in GitHub Desktop.
Save selfup/0caa1cdfeae55d2ac38b5b16d6942c15 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
REPOS=$1
CURRENT_DIR=$(pwd)
if [[ $REPOS == "" ]]
then
echo "please provide a directory with repositories to sync"
exit 1
fi
for path in $REPOS/*
do
if [[ -d $path/.git ]]
then
cd $path
git remote -v | grep -q "origin"
if [[ $? == "0" ]]
then
status=$(git status)
echo $status | grep -q "On branch master"
if [[ $? == "0" ]]
then
echo $status | grep -q "nothing to commit, working tree clean"
if [[ $? == "0" ]]
then
git pull origin master
fi
fi
fi
cd $CURRENT_DIR
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment