Created
December 16, 2016 21:34
-
-
Save josephoaks/8331372b15f059250569dc5560d83329 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/sh | |
sep='##########' | |
localpath=`pwd` | |
for x in */; do | |
x=`echo $x | sed s#/##` #Get repo name from base directory structure | |
header="$(tput setaf 1)$sep Processing $x $d$sep$(tput sgr0)" #Set header for printing repo info | |
head=`git -C $localpath/$x rev-parse --abbrev-ref HEAD` #Set head name | |
hash=`git -C $localpath/$x rev-parse HEAD` #Set head hash | |
echo $header #Print header | |
cd $localpath/$x #Change directory to working repo | |
remote=`git ls-remote upstream -h $head \ | |
$(git rev-parse --abbrev-ref @{u}|sed 's/\// /g') | cut -f1` #Set upstream hash for comparison | |
git -C $localpath/$x checkout $head #Ensure your on the HEAD | |
if [ $hash == $remote ]; #Compare local hash to upstream hash | |
then | |
echo "$(tput setaf 2)Everything is up to date$(tput sgr0)" #Print if nothing needs to update | |
else #else pull updates and update remote | |
git -C $localpath/$x pull upstream $head | |
git -C $localpath/$x push origin $head | |
fi | |
cd .. | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment