Question

I have the following case :

                      K---L new-feature
                     /
            H---I---J---M dev-team1
           /
          E---F---G dev-main
         /
A---B---C---D master

And I want to move only the new-feature (K---L) branch in dev-main branch without (H---I---J) form dev-team1, however I want that new-feature (K---L) branch to remain as a separate branch.

Something like that :

                      K---L new-feature
                     /
            H---I---J---M dev-team1
           /
          E---F---G---K'---L' dev-main
         /
A---B---C---D master
Était-ce utile?

La solution

This is a job for cherry-pick. Try

git checkout dev-main
git cherry-pick K
git cherry-pick L

You can also use the syntax described in the gitrevisions documentation to specify a range of commits. In this example you want to merge commits reachable from the new-feature branch but not from the dev-team1 branch, so you could write

git checkout dev-main
git cherry-pick dev-team1..new-feature

Also check this post about how to merge a specific commit in Git.

Autres conseils

you can merge ignore specifi commits H and I and merge the rest with dev-main from new-feature.

git - skipping specific commits when merging

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top