Skip to content

Instantly share code, notes, and snippets.

@AustinDizzy
Last active August 29, 2015 14:04
Show Gist options
  • Save AustinDizzy/f685fb40d6a4b5cbeac1 to your computer and use it in GitHub Desktop.
Save AustinDizzy/f685fb40d6a4b5cbeac1 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ -z "$1" ] || [ "$1" == "help" ] ; then
echo
echo "Usage: git check [remote]:[branch]"
echo
else
OPTS=(${1//:/ })
remote=${OPTS[0]}
branch=${OPTS[1]}
$(git fetch $remote)
remote_c=$(git rev-parse $remote/$branch)
local_c=$(git rev-parse $branch)
echo
printf "Local ($branch) : %s\nRemote ($branch): %s\n" $local_c $remote_c
echo
if [[ $local_c == $remote_c ]]; then
echo "Remote is up to date"
else
echo "Remote $1 is ahead or behind local $branch."
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment