How to create a patch for a new file?

advertisements

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


Add -N to the diff arguments.