简体   繁体   English

两个本地分支跟踪单独的远程Git仓库

[英]Two local branches track separate remote Git repos

I have one local repo with two branches 我有两个分支机构的一个本地仓库

  • master
  • private 私人的

I want the master branch to track origin/master from the public repo on Github. 我希望master分支可以跟踪Github上公共回购中的原始/ master。 I want the private branch to track origin_private/master from the private repo on Github. 我希望私有分支从Github上的私有仓库中跟踪origin_private / master。

Assuming this is a good idea/good setup, I have run into problems trying to make those two branches track separate remote repos. 假设这是一个好主意/良好的设置,我在尝试使这两个分支跟踪单独的远程存储库时遇到了问题。

For example, see this command history; 例如,请参阅此命令历史记录。 I have annotated it with my own remarks: 我用自己的话注释了它:

C:\Users\denman\WebstormProjects\suman>git branch
* master
  private

C:\Users\denman\WebstormProjects\suman>git branch -u origin/master master
Branch master set up to track remote branch master from origin. (cool thanks Git)

C:\Users\denman\WebstormProjects\suman>git checkout private
Switched to branch 'private'

C:\Users\denman\WebstormProjects\suman>git branch -u origin_private/master master
Branch master set up to track remote branch master from origin_private.
(cool thanks Git)

C:\Users\denman\WebstormProjects\suman>git pull
There is no tracking information for the current branch. (not cool Git!)
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=<remote>/<branch> private

Does anyone know what I am doing wrong? 有人知道我在做什么错吗? I issued the standard call to track a remote branch using the "git branch -u" command but it doesn't seem to work. 我发出了使用“ git branch -u”命令跟踪远程分支的标准调用,但似乎不起作用。

You first setup master to track origin/master , then you setup again master to track private_origin/master . 您首先设置master以跟踪origin/master ,然后再次设置master以跟踪private_origin/master In your second track command the last argument should be private . 在第二个track命令中,最后一个参数应该为private Actually as you have private checked out, you can leave out the last argument, our you can spare the checkout if you just want to set the tracking branch. 实际上,当您private检出时,可以省略最后一个参数,如果您只想设置跟踪分支,则可以省去检出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM