参见: 如何查看哪个Git分支正在跟踪哪个远程/上游分支?

如何知道本地分支正在跟踪哪个远程分支?

我是否需要解析git配置输出,或者是否有一个命令可以为我做这件事?


当前回答

git branch -vv | grep 'hardcode-branch-name'
# "git rev-parse --abbrev-ref head" will get your current branch name
# $(git rev-parse --abbrev-ref head) save it as string
#  find the tracking branch by grep filtering the current branch 
git branch -vv | grep $(git rev-parse --abbrev-ref head)

其他回答

下面的命令将远程原点电流叉指的是

Git remote -v

添加远程路径时,

Git远程添加原始路径_name

git branch -r -vv

将列出所有分支,包括远程分支。

我使用EasyGit(又名:EasyGit)。"eg")作为Git顶部(或旁边)的超轻量级包装器。EasyGit有一个“info”子命令,它为您提供各种超级有用的信息,包括当前分支的远程跟踪分支。下面是一个例子(当前分支名称是"foo"):

pknotz@s883422: (foo) ~/workspace/bd
$ eg info
Total commits:      175
Local repository: .git
Named remote repositories: (name -> location)
  origin -> git://sahp7577/home/pknotz/bd.git
Current branch: foo
  Cryptographic checksum (sha1sum): bd248d1de7d759eb48e8b5ff3bfb3bb0eca4c5bf
  Default pull/push repository: origin
  Default pull/push options:
    branch.foo.remote = origin
    branch.foo.merge = refs/heads/aal_devel_1
  Number of contributors:        3
  Number of files:       28
  Number of directories:       20
  Biggest file size, in bytes: 32473 (pygooglechart-0.2.0/COPYING)
  Commits:       62

本地分支机构及其遥控器。

git branch -vv 

所有分支和跟踪遥控器。

git branch -a -vv

查看本地分支在哪里显式地配置了推和拉。

git remote show {remote_name}

您可以使用git签出,即。“签出当前分支”。如果存在当前分支的跟踪信息,这是一个没有副作用的操作。

$ git checkout 
Your branch is up-to-date with 'origin/master'.