2

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
radu c
  • 4,138
  • 7
  • 30
  • 45

2 Answers2

4

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.

Community
  • 1
  • 1
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • What if I have many commits like : K,L,N,O,P? I will write the command `git cherry-pick SHA` for each? – radu c Jan 19 '14 at 13:31
  • @EkKosmos, I have updated my answer with information about specifying `K` and `L` together, which may be useful if you have many commits to `cherry-pick`. – ChrisGPT was on strike Jan 19 '14 at 13:42
0

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

Community
  • 1
  • 1
User123456
  • 2,492
  • 3
  • 30
  • 44