shell 判断git本地分支是否需要更新

#!/bin/sh

BRANCH=master

LOCAL=$(git log $BRANCH -n 1 --pretty=format:"%H")
REMOTE=$(git log remotes/origin/$BRANCH -n 1 --pretty=format:"%H")

if [ $LOCAL = $REMOTE ]; then
    echo "Up-to-date"
else
    echo "Need update"
fi
posted @ 2020-08-31 14:14  jasondayee  阅读(1826)  评论(0编辑  收藏  举报