Git - 每个分支的不同遥控器 [英] Git - Different Remote for each Branch
问题描述
我不确定如何正确地提出这个问题,但我会尽力而为 - 我绝不是Git爱好者,我知道如何使用基本命令,但不知道高级术语/功能。 我从私有服务器 基本上我希望能够 从Git 1.8.0开始: 您可以设置不同的分支来推送到单个分支的其他分支服务器: / strong> 注意:如果最后一个 从Git 1.7.0开始: 在你的情况下,你可以使用通过添加你的两个遥控器(mydomain和github)并设置每个分支来单独推送它们。它可能看起来像这样: 如果您还没有添加遥控器,请确保您已添加遥控器: 然后设置分支以推送到正确的地方: 完成所有设置后,只需使用 I'm unsure of how to ask this properly but I'll try and do my best - I'm by no means a Git aficionado, I know how to use the basic commands but not advanced terminology/functionality. I have a private repository Essentially I'd like to be able to You can set a different branch to push to a different server for individual branches by using these commands: As of Git 1.8.0: Note: If the last As of Git 1.7.0: In your case, you would use this by adding your two remotes (mydomain and github) and setting each branch to push to them individually. It might look something like this: Make sure you add the remotes if you haven't already: Then set the branches to push to the right places: After this is all set up, you can push and pull just by using 这篇关于Git - 每个分支的不同遥控器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
克隆了一个私有存储库
。我熟悉使用 myrepo
git.mydomain.com git checkout -b mybranch
在同一个存储库上分支代码的过程 - 但是我想分支到GitHub而不是我的私有服务器,在这样的事情:
回购分行远程位置(目的)
---------- --------------------------------------------------
myrepo - >私人 - > git.mydomain.com(增量工作)
|
+ ------>公开 - > github.com(公开发布)
git checkout public
和 git merge private
。
git branch -u origin / foo foo
foo
被省略,它将选择当前分支。
git branch --set-upstream foo origin / foo
git remote add github git://github.com/foo/myrepo.git
git remote add mydomain git://git.mydomain.com/foo/myrepo.git
git branch -u mydomain / private private
git branch -u github / public public
git push
和 git拉
。当你在公共分支上时,这会推送到github,当你在你的私人分支时,你会到你的mydomain.com。 myrepo
cloned from a private server git.mydomain.com
. I'm familiar with the process of branching code on the same repository with git checkout -b mybranch
- however I'd like to branch to GitHub rather than my private server, resulting in something like this:Repo Branch Remote Location (Purpose)
------------------------------------------------------------
myrepo --> private --> git.mydomain.com (Incremental work)
|
+------> public --> github.com (Public releases)
git checkout public
and git merge private
.git branch -u origin/foo foo
foo
is left out, it will choose the current branch. git branch --set-upstream foo origin/foo
git remote add github git://github.com/foo/myrepo.git
git remote add mydomain git://git.mydomain.com/foo/myrepo.git
git branch -u mydomain/private private
git branch -u github/public public
git push
and git pull
. This will push and pull to github when you're on the public branch, and to your mydomain.com when you're on your private branch.