如何在 git 中显示本地和远程分支之间的连接?
How to show connections between local and remote branches in git?
我想将远程分支 (origin/featureX
) 的副本添加到我的本地存储库。
因此我生成了一个本地分支 featureX
并将其设置为跟踪给定的远程分支:
git branch featureX
git branch -u origin/featureX featureX
# Branch featureX set up to track remote branch featureX from origin.
现在有办法显示这种联系吗?我试过了git branch -av
,但未显示 featureX
和 remotes/origin/featureX
之间的连接。
而不是 git branch
,试试 git checkout featureX
。
由于有一个 origin/featureX
分支,该本地分支将自动链接到远程跟踪分支。
先删除你的分支,然后重新创建它:
git branch -d featureX
git checkout featureX
来自 git checkout
:
If <branch>
is not found but there does exist a tracking branch in exactly one remote (call it <remote>
) with a matching name, treat as equivalent to
$ git checkout -b <branch> --track <remote>/<branch>
你需要更详细一些git branch -vv
,这是documented但不明显。
-v
-vv
--verbose
When in list mode, show sha1 and commit subject line for each head, along with relationship to upstream branch (if any). If given twice, print the name of the upstream branch, as well (see also git remote show ).
要轻松查看链接,请将 -v
选项加倍:
$ git branch -v
* master b9a3e01 [ahead 3]
$ git branch -vv
* master b9a3e01 [origin/master: ahead 3]
在大多数情况下,请参阅 以更方便地开始这些事情。
我想将远程分支 (origin/featureX
) 的副本添加到我的本地存储库。
因此我生成了一个本地分支 featureX
并将其设置为跟踪给定的远程分支:
git branch featureX
git branch -u origin/featureX featureX
# Branch featureX set up to track remote branch featureX from origin.
现在有办法显示这种联系吗?我试过了git branch -av
,但未显示 featureX
和 remotes/origin/featureX
之间的连接。
而不是 git branch
,试试 git checkout featureX
。
由于有一个 origin/featureX
分支,该本地分支将自动链接到远程跟踪分支。
先删除你的分支,然后重新创建它:
git branch -d featureX
git checkout featureX
来自 git checkout
:
If
<branch>
is not found but there does exist a tracking branch in exactly one remote (call it<remote>
) with a matching name, treat as equivalent to
$ git checkout -b <branch> --track <remote>/<branch>
你需要更详细一些git branch -vv
,这是documented但不明显。
-v
-vv
--verbose
When in list mode, show sha1 and commit subject line for each head, along with relationship to upstream branch (if any). If given twice, print the name of the upstream branch, as well (see also git remote show ).
要轻松查看链接,请将 -v
选项加倍:
$ git branch -v
* master b9a3e01 [ahead 3]
$ git branch -vv
* master b9a3e01 [origin/master: ahead 3]
在大多数情况下,请参阅