Last active
December 26, 2015 10:49
-
-
Save dustinmm80/7139336 to your computer and use it in GitHub Desktop.
Run this in your git directory to make sure you're working off the latest code.
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/bash | |
# Checks that your Github repos are up to date | |
DIRS=() | |
sync=$1 | |
for file in */ cookbooks/*; do | |
DIRS+=("`pwd`/${file}"); | |
done | |
for i in "${DIRS[@]}"; do | |
if [ -d "${i}/.git" ]; then | |
cd ${i} | |
latest_commit=$(echo `git ls-remote origin master` | cut -d' ' -f1) | |
current_commit=$(echo `git rev-parse HEAD`) | |
if [ "${current_commit}" != "${latest_commit}" ]; then | |
echo "${i} is not synced with origin!" | |
echo "syncing" | |
git pull --rebase origin master | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment