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
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.
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”.
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.
Add -N
to the diff
arguments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With