Skip to content

Instantly share code, notes, and snippets.

@jorgenschaefer
Created October 6, 2012 22:16
Show Gist options
  • Save jorgenschaefer/3846361 to your computer and use it in GitHub Desktop.
Save jorgenschaefer/3846361 to your computer and use it in GitHub Desktop.
#!/bin/sh
# check.sh origin
#
# This will fetch commits from origin, and then display the log of
# changes from origin back to when it first deviated from the current
# branch.
if [ -z "$1" ]
then
echo "usage: check <remote> [remotebranch]"
echo
echo "Possible values for remote:"
echo
git remote | sed 's/^/ /'
exit 1
fi
REMOTE="$1"
if [ -z "$2" ]
then
REMOTEBRANCH="master"
else
REMOTEBRANCH="$2"
fi
git fetch "$REMOTE"
CURRENT=$(git rev-parse HEAD)
BASE=$(git merge-base "$REMOTE/$REMOTEBRANCH" HEAD)
if [ "$CURRENT" = "$BASE" ]
then
echo "No new changes on $REMOTE/$REMOTEBRANCH"
else
git log $BASE..$REMOTE/$REMOTEBRANCH
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment