简体   繁体   中英

Git: Same feature on multiple branches, but not on master

Our supplier has provided the code to run the linux kernel on their hardware, however there are 2 kernel versions - one that they use for Android (kernel 2.6), another for Yocto (kernel 3.01). Now I've done some modifications to the hardware and added a few drivers to support the new hardware in kernel 2.6, as shown with X and Y, but I want to apply the same change to 3.01.

Now:

   E -- F -- G -- X -- Y (2.6)
 /
A -- B -- C -- D (master)
      \
       H -- I -- J (3.01)

After:

   E -- F -- G -- X -- Y (2.6)
 /
A -- B -- C -- D (master)
      \
       H -- I -- J -- X -- Y (3.01)

What would be the best way to go about it? I've read about cherry picking and that it isn't a good practice. I would like to avoid touching the master at all since my hardware is completely irrelevant to the mainline kernel development.

Any suggestions? Thanks!

Your commit diagram is impossible. You cannot have two different X and Y commits with different ancestors. Git cannot do that, there is no solution that can produce that commit graph.

The answer is (good practice or not) cherry picking, and a commit graph that looks like this:

   E -- F -- G -- X -- Y (2.6)
 /
A -- B -- C -- D (master)
     \
      H -- I -- J -- X' -- Y' (3.01)

Where X' and Y' are the cherry-picked versions of X and a Y .

Whatever made you think it isn't a "good practice" is irrelevant; it's the only way to arrive at the results you're after.

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