上游分支未存储为远程跟踪分支

时间:2014-12-19 13:35:23

标签: git bash branch

我正在编写一个git脚本来检查所有分支的更新。

if [[ -n $(git config --get branch.$SHORT.remote) ]]; then
    LOCAL=$(git rev-parse "$SHORT")
    REMOTE=$(git rev-parse "$SHORT"@{upstream})
    BASE=$(git merge-base "$SHORT" "$SHORT"@{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
else
    echo "No upstream configured."
fi

它给了我这个错误(两次,每个@ {上游}一次):

fatal: Upstream branch 'refs/heads/master' not stored as a remote-tracking branch
fatal: Upstream branch 'refs/heads/master' not stored as a remote-tracking branch

这是我的git branch -a

  master
* scrimmage
  remotes/origin/development
  remotes/origin/master
  remotes/origin/scrimmage
  remotes/origin/scrimmage-simple

什么?我不明白这个术语,除了在一些不明确的邮件列表中他们决定使用这个错误信息之外,找不到任何引用。

1 个答案:

答案 0 :(得分:1)

我是傻瓜;我之前写了一个脚本,显然添加了一行

branch.master.remote=returns 

到配置。因此,它试图访问一个实际上并不存在的遥控器。

[这个问题可以删除,因为它是一个特定的案例吗?]