对于应用程序,我需要知道从远程跟踪的分支。
我知道如何从远程创建不在本地的分支:
git checkout -t remote/branch
我知道如何获取本地分支的远程:
git rev-parse --abbrev-ref --symbolic-full-name branch@{u}
但是现在,我需要用 Remote 知道是否跟踪了某个分支,如果是,是哪个分支。
例如,如果我有一个名为 test 的分支,其远程是 toto/hello,我想要一个仅包含“toto/hello”的命令来返回 test。
提前致谢!
最佳答案
也许周围有什么
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 格式的条件语句)
关于git - 从远程跟踪分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55090119/