Last active
August 22, 2019 04:21
-
-
Save selfup/0caa1cdfeae55d2ac38b5b16d6942c15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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