Skip to content

Instantly share code, notes, and snippets.

@dustinmm80
Last active December 26, 2015 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustinmm80/7139336 to your computer and use it in GitHub Desktop.
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.
#! /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