简体   繁体   English

更改分支后合并提交

[英]Merge commits after changes to the branch

I've initially had two branches: 我最初有两个分支:

master A---B---C
                \
fork             D---E---F---H---I

So I wanted to get my fork branch to be merged to master at F, without merging D and E. So it becomes: 所以我想让我的fork分支合并到F的master上,而不合并D和E。因此它变成:

master A---B---C-------F---H---I
                \
fork             D---E

And then I would like to be able to rebase the fork to master, so it becomes: 然后,我希望能够将fork改组为master,因此它变为:

master A---B---C-------F---H---I
                                \
fork                             D---E

(Not sure about the lettering, or should it become D' and E' and have the old ones stay after C) (不确定字母,还是应该变成D'和E'并让旧字母留在C之后)

So I searched around and found that I can branch my fork at "I" and then hard reset it, but it became even more complicated: 因此,我四处搜索,发现可以将叉子分叉到“ I”,然后对其进行硬重置,但是它变得更加复杂:

master A---B---C
                \
fork             D---E
                      \
to-merge               F---H---I

(I'm at this point now) (我现在是这一点)

Please, help a noob at branching to make it work. 请帮助新手,使其分支工作。 Even it I end up with something like this: 甚至我最终还是这样:

master A---B---C-------F---H---I
                \     /         \
fork             D---E           D'--E'

I don't want to merge D and E to the master at all. 我根本不想将D和E合并到主服务器。

If it's only 3 commits, it might be simplest to just cherry-pick them into your master branch. 如果只有3次提交,将它们樱桃拾取到您的master分支中可能是最简单的。

git checkout master
git cherry-pick F
git cherry-pick H
git cherry-pick I

I think you may want to look at cherry picking. 我想您可能想看看樱桃采摘。

Just a quick google brought this up. 只是一个快速的谷歌提出了这一点。 Looks useful (and like what you need). 看起来很有用(并根据需要)。 http://technosophos.com/content/git-cherry-picking-move-small-code-patches-across-branches http://technosophos.com/content/git-cherry-picking-move-small-code-patches-across-branches

First check out master. 首先结帐大师。

$ git checkout master

Then something like this for each cherry pick. 然后每个樱桃采摘都这样。

$ git cherry-pick F
Finished one cherry-pick.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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