================================================================================
                              Manipulating patches
================================================================================

Generating a patch

It is possible to generate patchs using git.

$ mkdir patch_dir
$ cd patch_dir
$ git init

Copy the file to patch
$ cp ../file ./
$ git add file
$ git commit -m "Init"

Modify it
$ edit file

Creating the patch
$ git diff > patch.patch

git diff patch from working tree against last commit by default. See git-diff
for more options.

--------------------------------------------------------------------------------

Applying a patch

The patch is applied based on the patch witten in the patch. So the filetree
must either be correct or the command line must precisely tell what to do. patch
reads from stdin by default.

$ patch -p1 -d ~/myapp < ~/patches/my_patch.patch

-d changes directory before doing anything. Useful if the patch is somewhere
else.
-pX strips X at the beginning of the path in the patch. -p1 is Useful to strip 
the auto-generated a/ and b/ by git diff. Not specifying it results in a full
strip.

To ignore the path:
$ patch /path/to/target/file < ~/patches/my_patch.patch

--------------------------------------------------------------------------------
