merlin2011
merlin2011

Reputation: 75589

How do I create a patch from one branch to another using only a subset of the files that were changed?

That is, suppose I want a patch that will take me from branch1 to branch2, but I only care about files foo1.c and foo2.c, whereas other files also changed between the two branches.

How can I make a patch including exactly these two files?

If I just do git diff branch1 branch2 > Change.patch, I will get all the files.

If I just do git diff branch1:foo1.c branch2:foo1.c > Change.patch, I only get the patch for one file.

Upvotes: 1

Views: 125

Answers (1)

twalberg
twalberg

Reputation: 62479

Something along these lines should work:

git diff branch1 branch2 -- foo1.c foo2.c > change.patch

Upvotes: 1

Related Questions