如何保持分支与master同步/更新? [英] How to keep a branch synchronized/updated with master?

查看:159
本文介绍了如何保持分支与master同步/更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当git进入我的脑海时,我无法为以下问题提供最佳解决方案.

At the moment git is doing my head in, I cannot come up with the best solution for the following.

有两个分支,一个叫 master ,另一个叫 mobiledevicesupport .我想将mobiledevicesupport保持为连续分支,只要mobiledevicesupport稳定,它将与master分支合并/同步.这样既可以将移动设备支持中的更改合并到主设备中,也可以将主设备中的所有更改都并入移动设备支持中,以便可以继续处理分支,并改进或修改功能.这需要与一个中央存储库和多个开发人员一起使用.

There are two branches, one called master and one called mobiledevicesupport. I want to keep mobiledevicesupport as a continuous branch that will be merged/synced with the master branch whenever mobiledevicesupport is stable. This would merge changes from mobiledevicesupport into master but also bring all the changes from master into mobiledevicesupport so that branch can continue to be worked on and the features improved or amended. This needs to work with a central repository and multiple developers.

请举一个其他人使用的类似工作流程的示例,或者只是告诉我这个想法是否愚蠢,我应该考虑其他选择.目前,工作流程听起来不错,但我只是不知道如何使git以这种方式工作.

Please an example of similar workflows other people use or just tell me if this idea is stupid and I should consider other options. At the moment the workflow seems sound, but I just don't know how I can make git work this way.

谢谢,所有帮助都很感激.

Thanks, all help much appreciated.

更新1:如果我要将master合并到mobiledevicesupport中,并且将mobiledevice支持合并到master中,我是否会在两个分支之间获得复制的提交.还是git足够聪明,可以算出我已将最新的更改从分支A拉到分支B并将合并提交C添加到分支B.而且我已将最新的更改从分支B拉到分支A并将合并提交D添加到分支是吗?

Update 1: If I was to merge master into mobiledevicesupport and mobiledevice support into master, do I get replicated commits across both branches. Or is git smart enough to work out that I have pulled the latest changes from branch A into branch B and add merge commit C to branch B. And I have pulled the latest changes from branch B into branch A and add merge commit D to branch A?

本来要发布图像,但是我没有足够的声誉,因此,我想下面的插图必须要做.连续运行的两个分支通常会双向合并.我不确定的关键是git如何播放提交内容,并在合并时将其中一个分支的内容填充到另一个分支中,还是保持干净.我以前使用过rebase,但似乎结束了分支并将所有提交放入master,否则我做错了.感谢到目前为止的帮助.

I was going to post an image but I don't have enough reputation for it, so I guess the following illustration will have to do. Two branches continuously running with merges going both directions often. The key thing I am not sure about is how git will play out the commits and will it fill either branch with the commits from the other branch on merges or will it stay clean. I have used rebase before but it seems to end the branch and put all the commits into the master, or I did it wrong. Thanks for the help so far.

master
A--B--C-----H--I--J--M--N
       \   /    \
mobile  \ /      \
D--E--F--G--------K--L

推荐答案

是的

git checkout master
git pull
git checkout mobiledevicesupport
git merge master

使移动设备支持与主机保持同步

to keep mobiledevicesupport in sync with master

然后,当您准备好将移动设备支持放入主机中时,首先像上面那样合并到主机中,然后...

then when you're ready to put mobiledevicesupport into master, first merge in master like above, then ...

git checkout master
git merge mobiledevicesupport
git push origin master

就这样.

这里的假设是mobilexxx是一个主题分支,其工作尚未准备好进入您的主分支.因此,只有在适当的位置获得移动设备支持后,才能合并到主设备中

the assumption here is that mobilexxx is a topic branch with work that isn't ready to go into your main branch yet. So only merge into master when mobiledevicesupport is in a good place

这篇关于如何保持分支与master同步/更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆