Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create patch for a new file?

Tags:

c

linux

patch

I know to create a patch for an existing file is easy:

diff -aru oldFile newFile 2>&1 | tee myPatch.patch

But what to do, if i want to create a patch for a totally new file? Assume my file is residing in a folder called TestDir. Earlier TestDir did not have a file called entirelyNewfile.c, but now it is having the same.

How to create a patch for entirelyNewfile.c? The idea is, the patch should get properly applied to the specs and generate the RPM build. With BUILD dir having this new file.

Just to add: if i try to take diff between the two directories, one having the new file and the other missing the same, to create the patch, it generates an error saying that file is only present in one folder

like image 535
RajSanpui Avatar asked Apr 11 '11 15:04

RajSanpui


People also ask

How do I apply a patch to a file?

Using diff With Directories We can use diff to create a patch file that contains all of the differences between the files in two directories. We can then use that patch file with patch to have those differences applied to the files in the working folder with a single command.

How do I create a patch code?

A patch is created by using the diff command to compare two directories: one directory contains the original version of the source code, and the other directory contains the new version of the source code. The output of the diff command is captured in a text file, which is the “patch”.

How do I create a patch file in Windows?

The easiest way to create a patch in Windows is by using WinMerge. Winmerge is one of the most popular applications for comparing files and it already reached a de-facto standard. The procedure for creating a patch file is pretty straightforward.


1 Answers

Add -N to the diff arguments.

like image 108
Ignacio Vazquez-Abrams Avatar answered Sep 22 '22 09:09

Ignacio Vazquez-Abrams