Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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?

like image 516
jospratik Avatar asked Jan 07 '14 11:01

jospratik


People also ask

How do I read a patch file?

The patch file (also called a patch for short) is a text file that consists of a list of differences and is produced by running the related diff program with the original and updated file as arguments. Updating files with patch is often referred to as applying the patch or simply patching the files.


1 Answers

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.

like image 104
Johnsyweb Avatar answered Oct 28 '22 02:10

Johnsyweb