从远程跟踪的分支

Branch tracked from a remote

对于应用程序,我需要知道从远程跟踪的分支。

我知道如何从远程创建一个不在本地的分支:

git checkout -t remote/branch

我知道如何获取本地分支的远程:

git rev-parse --abbrev-ref --symbolic-full-name branch@{u}

但是现在,我需要用遥控器知道是否跟踪了一个分支,如果是,是哪个分支。

例如,如果我有一个名为 test 的分支,它的远程是 toto/hello,我想要一个只有 'toto/hello' 的命令来给 returns 我测试。

提前致谢!

可能是附近的事情

git for-each-ref --format='%(if:equals=toto/hello)%(upstream:short)%(then)%(refname:short)%(else)%(end)' refs/heads

git for-each-ref --format='%(if:equals=toto/hello)%(push:short)%(then)%(refname:short)%(else)%(end)' refs/heads

?

doc for-each-ref 格式的条件语句)