Skip to content

Instantly share code, notes, and snippets.

@csanz
Created May 6, 2019 21:30
Show Gist options
  • Save csanz/1541bd990ebf81c1c25d79f9942598d4 to your computer and use it in GitHub Desktop.
Save csanz/1541bd990ebf81c1c25d79f9942598d4 to your computer and use it in GitHub Desktop.
Another way to check if the repo was updated.
# picked up from stackoverflow
UPSTREAM=${1:-'@{u}'}
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse "$UPSTREAM")
BASE=$(git merge-base @ "$UPSTREAM")
if [ $LOCAL = $REMOTE ]; then
echo "Up-to-date"
elif [ $LOCAL = $BASE ]; then
echo "Need to pull"
elif [ $REMOTE = $BASE ]; then
echo "Need to push"
else
echo "Diverged"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment