目前git正在做我的头,我不能提出以下最好的解决方案。

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以这种方式工作。

谢谢,非常感谢所有的帮助。

更新1: 如果我将master合并到mobiledevicesupt中,并将mobiledevicesupport合并到master中,我是否会在两个分支之间复制提交?或者git是否足够聪明,可以计算出我已经将最新的更改从分支A拉到分支B,并将合并提交C添加到分支B。我已经将最新的更改从分支B拉到分支A,并将合并提交D添加到分支A?

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合并可以完成工作,但会留下一个混乱的提交历史,正确的方法应该是通过以下步骤“rebase”(假设你想在做PR前的最后推送之前保持你的功能分支与开发同步)。

从你的特性分支中获取1个git(确保你正在使用的特性分支是最新更新的)

2 git rebase origin/develop

如有冲突,应逐一解决

4使用git rebase—在所有冲突处理完毕后继续

5个git推——力

其他回答

通过git合并可以完成工作,但会留下一个混乱的提交历史,正确的方法应该是通过以下步骤“rebase”(假设你想在做PR前的最后推送之前保持你的功能分支与开发同步)。

从你的特性分支中获取1个git(确保你正在使用的特性分支是最新更新的)

2 git rebase origin/develop

如有冲突,应逐一解决

4使用git rebase—在所有冲突处理完毕后继续

5个git推——力

是的,只要做:

git checkout master
git pull
git checkout mobiledevicesupport
git merge master

保持移动设备支持与主同步。

然后,当你准备好把mobiledevicsupport放到master中,首先,像上面那样合并在master中,然后:

git checkout master
git merge mobiledevicesupport
git push origin master

就是这样。

这里假设mobilexxx是一个主题分支,其中的工作还没有准备好进入您的主分支。所以只有在mobiledevicessupportionenabled好的时候才合并到master。

concept47的方法是正确的方法,但我建议合并使用——no-ff选项,以保持提交历史记录清晰。

git checkout develop
git pull --rebase
git checkout NewFeatureBranch
git merge --no-ff master

当你想要把master的更改放到你的工作分支中时,执行git rebase <remote>/master。如果有任何冲突。解决这些冲突。

当你的工作分支准备好了,重新设置base,然后执行git push <remote> HEAD:master。这将在远程(中央回购)上更新主分支。

执行如下命令:

$ git checkout mobiledevice
$ git pull origin master 

这将合并所有最新提交到您的分支。如果合并导致一些冲突,则需要修复它们。

我不知道这是否是最好的做法,但对我来说是有效的。