Bash git diff branch\u a branch\u b返回true或false

Bash git diff branch\u a branch\u b返回true或false,bash,git,bitbucket,git-bash,bitbucket-pipelines,Bash,Git,Bitbucket,Git Bash,Bitbucket Pipelines,我对bash脚本编写相当陌生,我正在尝试构建一个脚本来比较bitbucket中两个不同repo中的分支 目前,我有以下代码: if [[ clone -eq 0 ]]; then cd ${1} echo " ******************************** CLONE SUCCESSFUL. ADDING $BB_COMPARE AS REMOTE REPO... *******************************

我对bash脚本编写相当陌生,我正在尝试构建一个脚本来比较bitbucket中两个不同repo中的分支

目前,我有以下代码:

if [[ clone -eq 0 ]]; then 
    cd ${1}
    echo "
    ********************************
    CLONE SUCCESSFUL. 
    ADDING $BB_COMPARE AS REMOTE REPO...
    ********************************
    "
    add_remote=$(git remote add -f b $BB_COMPARE)

    echo "
    ************************************
            UPDATING REMOTE
    ************************************
    "
    git remote update
    echo "
    ************************************
    CHECKING DIFFERENCE
    ************************************
    "
    git_diff=$(git diff master remotes/b/master)
    fi
    if [[ git_diff -eq 0 ]]; then 
    echo "
    ************************************
    ERROR: $1 AND $compare are NOT in sync. 
    ************************************
    "

我认为git diff是我想要的,但我可能错了

我通常会数行。。。。即使有地位,因为你不知道它会有多大:

lines=$( git diff --name-only master remotes/b/master | wc -l )
if [ $lines -gt 0 ]; then
    echo "There are differences"
fi
为什么不呢?