找出本地分支正在跟踪的远程分支

也可以看看:
我该如何让git向我展示哪些分支正在跟踪什么?

如何找出本地分支正在跟踪的远程分支?

我需要解析git config输出,还是有一个命令会为我做这个?


这是一个给你跟踪分支的命令:

$ git branch -vv
  main   aaf02f0 [main/master: ahead 25] Some other commit
* master add0a03 [jdsumsion/master] Some commit

你必须通过SHA和任何长时间提交的提交消息,但它很快打字,我得到的跟踪分支在第3列垂直对齐。


更新

从git 1.8.5版开始,你可以显示上游分支的git statusgit status -sb


两个选择:

% git rev-parse --abbrev-ref --symbolic-full-name @{u}
origin/mainline

要么

% git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD)
origin/mainline

我认为git branch -av只会告诉你你有哪些分支以及他们git branch -av哪些提交,让你推断出当地分支正在追踪哪些远程分支。

git remote show origin明确告诉你哪些分支正在跟踪哪些远程分支。 以下是一个存储库的示例输出,其中包含一个提交和一个名为abranch的远程分支:

$ git branch -av
* abranch                d875bf4 initial commit
  master                 d875bf4 initial commit
  remotes/origin/HEAD    -> origin/master
  remotes/origin/abranch d875bf4 initial commit
  remotes/origin/master  d875bf4 initial commit

$ git remote show origin
* remote origin
  Fetch URL: /home/ageorge/tmp/d/../exrepo/
  Push  URL: /home/ageorge/tmp/d/../exrepo/
  HEAD branch (remote HEAD is ambiguous, may be one of the following):
    abranch
    master
  Remote branches:
    abranch tracked
    master  tracked
  Local branches configured for 'git pull':
    abranch merges with remote abranch
    master  merges with remote master
  Local refs configured for 'git push':
    abranch pushes to abranch (up to date)
    master  pushes to master  (up to date)
链接地址: http://www.djcxy.com/p/27117.html

上一篇: Find out which remote branch a local branch is tracking

下一篇: How to replace a parameterized type with a more specific one