简体   繁体   中英

Git: Syncing branches of 2 remote repositories

I am working on project which is on 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. 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?

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 :

git checkout develop

git branch -u origin/develop

This will cause all your future commits to be pushed to the upstream develop branch.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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