slo-loris
slo-loris

Reputation: 23

Cherry-picking all commit history of a particular file

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??

Upvotes: 0

Views: 1126

Answers (1)

exussum
exussum

Reputation: 18578

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

Upvotes: 1

Related Questions