This post applies to any Linux, Unix, or Mac-terminal users.
A patch file is one of the best methods to do what you think it would do—patch things. This short guide will teach you how to create patch files, and apply them to your files.
Creating Patch Files
Creating patch files requires two things—the original file and the new modified file you have created, that you would like to create a patch for. Run this command respectively:
diff -Naur <original file> <modified file> >> my_patch.patch
Of course, you can change the patch-file’s filename to whatever you would like. Here’s an example of creating a patch:
diff -Naur original.txt modified.txt >> modified.patch
Applying Patch Files
Now we can use this newly-created patch file to patch this same file so it is updated on other people’s systems. To patch a file, run this command, replacing with correct values:
patch -u <original file> <patch file>
For example, let’s patch another original.txt on another system using the patch file we created earlier:
patch -u original.txt modified.patch
That’s really all there is to patching!