How do I apply a patch?
The answer to this depends on how the patch was created, specifically to which directory the patch is done from. In general though, patches are done in the root of the source tree (/usr/src/linux), and the following assumes this.
We used the --dry-run option to check that the patch applies cleanly. This can be a life-saver sometimes as it can be a real pain to back out a partially-applied patch. The -p1 option strips off part of the diff file's pathnames for each changed file (see the patch(1) manpage for more details). Now you've checked that it should apply cleanly, run the following to actually apply it. Then you're done!
The situation with other patches is not always so simple. For example, Linus' pre patches (found in pub/linux/kernel/testing) are not incremental, That is pre10.bz2 must be applied on top of the tarball of the previous full release kernel. Eg, patch-2.4.8-pre2 goes on top of an unpacked 2.4.7 tarball, *not* on top of a patched 2.4.8-pre1 kernel. If you have a 2.4.8-pre1 kernel, you can get back to 2.4.7 by following the section 'Reversing a patch' below.
Occasionally you may want to test a patch from linux-kernel or similar. Generally these will be incremental against the named version (so, say, 2.4.0-test1-ac22-hosedmm.diff should be applied against 2.4.0-test1-ac22), and relative to the root. You may need to play with the -p option.
Reversing a patch
You've applied several patches, and now you want to remove them. Simply use the -R option to patch, with the same patch file, to back out the patch (alas, the patch(1) manpage is less than clear on this).
Patching using git
Points to note while applying patch from e-mails.
A majority of the patches are circulated through e-mail body (as opposed to attachments). Some mail clients (notably gmail web interface) would not show <TAB> character as a single char. Instead you would end up TABs replaced by spaces. Sometimes, you might get wrong patch or broken patch messages from git/patch. You can avoid such problems by using the raw data view (generally supported in all web based mails including yahoo! and gmail) to copy the patches from. Raw view does not render tabs as spaces and space only lines as empty lines.