这是而不是Find out which remote branch a local branch is tracking,如果我有多个遥控器,我可能在所有这些遥控器中都有“主控”。 git branch
返回主,但我不知道如果我在主分支是在remoteFoo或remoteBar。例如,我可能会做:找出当地分支正在跟踪哪个远程
git clone someRepo.git
cd someRepo
git remote add anotherRemote otherremoteURL
然后git remote
显示
someRepo
anotherRemote
我可以做git checkout -b master someRepo/master
或git checkout -b master anotherRemote/master
和git branch
会说 “主人”,在这两种情况下。如何取回第一部分“someRepo”或“anotherRemote”?
你会认为我可以使用git remote show
,但它需要一个参数,你想要的信息的远程名称。
$ git remote show origin
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
$ git remote show
someRepo
anotherRemote
随着git branch
我得到的是什么电流指示:
$ git branch
hold
* master
old-stuff
refactor
但git remote
输出没有 “*”。
究竟它是如何不一样,所引用的问题? [这个答案](http://stackoverflow.com/questions/171550/find-out-which-remote-branch-a-local-branch-is-tracking/7733266#7733266)似乎给出了跟踪远程分支的详细信息由你当地的分支机构;如果你做'git checkout someRepo/master',git会明确地告诉你,你处于分离的HEAD状态,'git branch'会像你想象的那样说'(不分支)',而不是'master'。 – lanzz
也许我错过了它,但在这个问题中我没有看到任何命令显示了当前分支的远程控制台,只显示了分支名称。 –
'git branch'给你当前分支的名称,'git remote show origin'告诉你哪个本地分支跟踪哪个远程分支。可能不会有特定的命令以特定的方式处理您的特定情况。 – lanzz