Partial git apply

Since git version 1.7.12, git apply has a --3way (or -3) option which will:

  1. Apply any changes it can figure out and stage them (i.e.: add them to the working tree and index),
  2. Add any new files and stage them (i.e.: add them to the working tree and index), and,
  3. When it encounters a merge conflict, it will, for each conflicting hunk:

    1. Put the code from the branch you are patching between <<<<<<< ours and ======= markers, and,
    2. Put the code from the patch file between ======= and >>>>>>> theirs markers.

    ... files with conflicts will not be staged: you'll have to manually fix them and git add them afterwards.


Try git apply --reject <patchfile>

Tags:

Git