4

I have a git repository with Android kernel v3.0.36. But now, Linux 3.0.38 is out. Android and mainline Linux are incompatible, so I just want to pull the changes from 3.0.37 and 3.0.38 (just a small part of changes). And I don't want to pull other changes.

I'm using Github. I saw many people's logs are like that:

net: wireless:bcm4329: Fix Unknown escape '%' 90fcf01d79 Browse code Choi, Jong-Hwan authored 8 months ago xxx committed 3 months ago

How can they do it? And how can I do it?

比尔盖子
  • 2,693
  • 5
  • 37
  • 53
  • There are ~90 changes between .36 and .38. It will be a bit hard to cherry-pick some without making a mess of dependencies... – fork0 Jul 23 '12 at 15:14

2 Answers2

3

You can fetch the other branch in your repository and cherry-pick the commits you need. See git cherry-pick, or alternatively git show --pretty=email <commit-id> |git am -3, or even git format-patch -o /tmp v3.0.37..v3.0.38, followed by git am -3 /tmp/<file> for the interesting, and possibly edited, patches

fork0
  • 3,401
  • 23
  • 23
  • OK, this is the things I want. But, I just want to pull the changes from 3.0.37 and 3.0.38 (just a small part of changes). And I don't want to pull other changes. If I pull mainline Linux into a branch of my repository, then I have to merge everything! – 比尔盖子 Jul 23 '12 at 15:56
  • Don't do this, than. The format-patch command in given in the example extracts just the patchs from .37 to .38 – fork0 Jul 23 '12 at 16:13
1

As in "Create a single patch between two tags with multiple commits between them", you could create a single path between v3.0.36. and 3.0.38, specifying the subdirectory which is of interest to you within one repo.

git diff tag1 tag2 -- /path/to/subdir > the-patch.diff

The idea is, you can apply a diff to another repo.

Regarding GitHub, the same mechanism apply with pull requests: once you have patched locally, you can push to our GitHub repo which should be a fork, and then make a pull request.


As fork0 comments, git diff would loose the comments associated with the commit.
git format-patch is a better solution (and I upvoted fork's answer).
I would consider cherry-pick only if you are aware of its limitation.


As commit like this one is the result of a pull request done by gregkh, accepted by edoko.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I'm using Github. I saw many people can do it easily. I need to see logs on Github like that: net: wireless:bcm4329: Fix Unknown escape '%' Choi, Jong-Hwan authored 8 months ago someone committed 3 months ago – 比尔盖子 Jul 23 '12 at 12:12
  • @比尔盖子 : I have edited my answer. could you also provide a link to one of those commits you see on GitHub? – VonC Jul 23 '12 at 14:15
  • Don't use `git diff` for this, you'll loose commit descriptions, which are as valuable as the changes themselves – fork0 Jul 23 '12 at 15:11
  • @VonC OK, see this commit: https://github.com/biergaizi/AIR-Kernel_ICS/commit/27aec2107c6c9f0aea46ebc011ee17357ee8e784 – 比尔盖子 Jul 23 '12 at 15:42