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
#!/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