jospratik
jospratik

Reputation: 1674

How can I apply a particular file from a Git patch file?

I have a Git patch consisting 6 files.

  1. abc.php
  2. pqr.php
  3. zyz.php
  4. rrr.php
  5. ggg.php
  6. yyy.php

I want to apply only rrr.php from the .patch file consisting the above files

git-apply command includes an --exclude arg, but not --include.

How can I apply only rrr.php from the .patch file?

Upvotes: 17

Views: 12565

Answers (1)

johnsyweb
johnsyweb

Reputation: 141928

You say:

git-apply command includes an --exclude arg, but not --include

The git-apply(1) Manual Page says:

--include=<path-pattern>

Apply changes to files matching the given path pattern. This can be useful when importing patchsets, where you want to include certain files or directories.

Try:

git apply --include=rrr.php some.patch

Verified with Git version 1.8.4.

Upvotes: 25

Related Questions