If you make contributions as a coder or else if you want to apply them in your code you will probably stumble upon '''diff''' and '''patch '''tools. They are frequently used in the Open Source Software specially on the Linux kernel. So, let's say you took some code, made some adjustments/improvements of your own and you want to share it to everyone else. One way is to share all the files you changed which shall be replaced by whoever wants to try your changes. This process requires more data and resources and doesn't make it very clear to everyone who his interested in understanding the differences before submitting your code. Besides if someone else makes some change on one or more of these files, sharing the complete files would replace your changes even if they were done in different parts of the code. So, for serious development you should embrace this option and try the diff/patch way.
- First generate a patch for others to apply.
- For this we use "diff" where the first argument shall be the original file or directory where did you started making the modifications and the second should be a version of the file or directory with the modifications already made.
- diff -Naur old_file new_file > your_patch_filename.patch
- or (if applied against directories)
- diff -Naur old_dir new_dir > your_patch_filename.patch
- Finally, to apply these patches you use the '''patch '''tool:
- patch -p0 < patch_filename.patch
- Note: This should be applied on the same relative directory where diff was executed. If you don't know which one it is you can check the patch file with any editor and try to figure that out.
You need to login to post a comment.