0

Suppose I want to cherry-pick full commit history of a particular file of a repo but the repo has more than one file and the commits are not even i.e 1st commit is to the particular file I wanted to cherry-pick and 2nd and 3rd is to some other and 4th to the particular file and so..

In this case how can my cherry-pick all the commits in one shot of that particular file excluding the commits that are done to other files..

I know,

$ git cherry-pick abc^..xyz

the command above wont work as it would cherry-pick the other commits which i wanna exclude also..

So my question is, Is there any way to do my requirement in a single command??

slo-loris
  • 23
  • 6
  • Does any commit updating more than one file ? If it is the case, you will have some conflict. – Ôrel Mar 11 '15 at 14:17
  • ya actually...I will be clear enough sir....from the linux repo i want to cherry-pick all the changes commited to zSwap.c ....so some commits may also update more than one file...in this case is there any possibilities?? – slo-loris Mar 11 '15 at 14:20

1 Answers1

1

Do you need the commit history also ?

One option is

git show <treeish>:<file>

and then just commit the file, Though it effectively "squashes" the commit

You could use this too

How to cherry pick only changes for only one file, not the whole commit

git diff <branch>^..<branch> -- <filename> | git apply
Community
  • 1
  • 1
exussum
  • 18,275
  • 8
  • 32
  • 65
  • tqsm...The second one worked...I saw diff from commit to commit basis instead of branch :) ...tanx for the answer... – slo-loris Mar 11 '15 at 16:36