Skip to content

Instantly share code, notes, and snippets.

@herzi
Created June 24, 2010 11:48
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 herzi/451351 to your computer and use it in GitHub Desktop.
Save herzi/451351 to your computer and use it in GitHub Desktop.
#!/bin/bash
if ! git rev-parse --git-dir > /dev/null; then
echo "This is not a git directory"
exit 1
fi
if test $# -lt 1; then
remote=origin
else
remote=$1
fi
git ls-remote $remote | while read LINE; do
commit=`echo $LINE | sed 's/ .*//'`
name=`echo $LINE | sed 's/.* //'`
if [ -z $name ]; then
continue;
fi
case $name in
refs/heads/master)
continue
;;
refs/heads/*)
shortname=`echo $name | sed 's@.*/@@'`
if ! git log --max-count=1 --pretty=format:"Branch '$shortname' -- last commit was %ar by %an (%h)" $commit 2>/dev/null; then
echo "your checkout doesn't contain commit `echo $commit | sed 's/^\(.......\).*/\1/'` for branch $shortname"
exit 1
fi
;;
esac
done
# vim:set et sw=8:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment