Add 'git-UpdateCheck.sh'
This commit is contained in:
17
git-UpdateCheck.sh
Normal file
17
git-UpdateCheck.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#Git update checker
|
||||
git remote update
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user