Creating and applying a patch with diff and patch
this post describes to save and apply changes to an source file.
Let us assume you want to alter the file src/tuwien/auto/calimero/server/Launcher.java and from the changes you want to create a patch.
First make a copy of the origin file.
michael@debdev ~# cp src/tuwien/auto/calimero/server/Launcher.java src/tuwien/auto/calimero/server/Launcher.java.org
Then make some changes to the file and create the patch. Note the options -Nar also work for directories recursive. For a single file -u3 is sufficient.
michael@debdev ~# vi src/tuwien/auto/calimero/server/Launcher.java michael@debdev ~# diff -Nar -u3 src/tuwien/auto/calimero/server/Launcher.java.org src/tuwien/auto/calimero/server/Launcher.java > myPatch.txt
Restore the origin file and apply the patch
michael@debdev ~# patch src/tuwien/auto/calimero/server/Launcher.java < myPatch.txt