Partial git apply
Since git version 1.7.12, git apply
has a --3way
(or -3
) option which will:
- Apply any changes it can figure out and stage them (i.e.: add them to the working tree and index),
- Add any new files and stage them (i.e.: add them to the working tree and index), and,
When it encounters a merge conflict, it will, for each conflicting hunk:
- Put the code from the branch you are patching between
<<<<<<< ours
and=======
markers, and, - 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.- Put the code from the branch you are patching between
Try git apply --reject <patchfile>