Lets say you've fixed a bug in a piece of software, and you now want to share your fix with the "upstream" author or distribution packager, so that you don't need to keep applying this patch to new versions, and that other people can benefit from it.
- Use "cvs diff -u" to generate the patch if you got the source from cvs(1) - everyone knows what that is. Developers have scripts to automatically apply a "cvs diff -u" style patch (figuring out -p properly etc). CVS also tells you what versions things are applied against, if people need to work back towards what versions you have. Otherwise (if it didn't come from cvs) do a "diff -u" from the top level directory of the /modified/ rather than in the cwd of the /original/. This means that normally you can just apply the patch with "patch -p0" and it "just works".
- Send it as an attachment unless explicitly asked otherwise. Otherwise your patch might get wordwrapped and this can cause a lot of confusion.
- It's often sensible to use the extra flags -w and -b to diff to ensure that you're not changing extraneous whitespace in your patch.
See the patch(1) and diff(1) ManPages for usage and descriptions of the options.