简体   繁体   中英

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:

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:

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)

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:

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.

If it's only 3 commits, it might be simplest to just cherry-pick them into your master branch.

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

First check out master.

$ git checkout master

Then something like this for each cherry pick.

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

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