Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
628 views
in Technique[技术] by (71.8m points)

git - 找出本地分支正在跟踪哪个远程分支(Find out which remote branch a local branch is tracking)

See also:

(也可以看看:)
How can I see which Git branches are tracking which remote / upstream branch?

(如何查看哪个Git分支正在跟踪哪个远程/上游分支?)

How can I find out which remote branch a local branch is tracking?

(如何找出本地分支正在跟踪哪个远程分支?)

Do I need to parse git config output, or is there a command that would do this for me?

(我需要解析git config输出,还是有一个命令可以帮我做到这一点?)

  ask by Readonly translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Here is a command that gives you all tracking branches (configured for 'pull'), see:

(是一个为您提供所有跟踪分支(配置为“拉”)的命令,请参见:)

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

You have to wade through the SHA and any long-wrapping commit messages, but it's quick to type and I get the tracking branches aligned vertically in the 3rd column.

(您必须仔细阅读SHA和所有长时间包装的提交消息,但是键入起来很快,我在第三列中将跟踪分支垂直对齐。)

If you need info on both 'pull' and 'push' configuration per branch, see the other answer on git remote show origin .

(如果您需要每个分支上的'pull'和'push'配置信息,请参阅git remote show origin上的其他答案。)


Update

(更新资料)

Starting in git version 1.8.5 you can show the upstream branch with git status and git status -sb

(从git版本1.8.5开始,您可以显示带有git statusgit status -sb的上游分支)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...