[英]Git: Syncing branches of 2 remote repositories
I am working on project which is on bitbucket. 我正在研究在bitbucket上的项目。 I forked existing repository for my team and we are working on it.
我为团队分叉了现有的存储库,我们正在努力。 Bitbucket automatically shows if my repository is behind source repo and will sync it.
Bitbucket会自动显示我的存储库是否在源回购之后,并将对其进行同步。 But It syncs master branch of source repo with master branch of my repo.
但是它将源仓库的主分支与我仓库的主分支同步。 But source repo maintainer asked to always sync his develop branch and only commit to my develop branch.
但是源回购维护者要求始终同步他的开发分支,并且只提交给我的开发分支。 So I want to know how to sync develop branch of source repo with my repo develop branch.
所以我想知道如何将源回购开发分支与我的回购开发分支同步。
I am not sure if it has something to do with adding 2 remotes and syncing them locally and pushing? 我不确定是否与添加2个遥控器并将它们在本地同步并推送有关?
You can checkout the exact remote branch with the statement: 您可以使用以下语句检出确切的远程分支:
git checkout -b origin/develop
If you already have a local develop
branch that earlier pulled from master, you can edit its remote upstream branch by this command : 如果您已经有一个本地
develop
分支,该分支先前已从master分支中拉出,则可以通过以下命令编辑其远程上游分支:
git checkout develop
git branch -u origin/develop
This will cause all your future commits to be pushed to the upstream develop
branch. 这将导致您将来的所有提交都被推送到上游
develop
分支。
add two separate remote with repo name so there is no confusion if you have same code on both repo .Then if need pull from repo1 use 添加两个带有回购名称的单独的远程服务器,因此如果两个回购上都具有相同的代码,则不会造成混乱。然后如果需要从回购1中使用
git pull repo1 develop
then 然后
git push repo2 develop
To add multiple remote use 添加多个远程使用
git remote add remote-name remote-url
To rename existing remote use 重命名现有的远程使用
git remote set-url remote-name remote-url
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.