I have a very large patch file that I'm trying to apply to my code. The problem is, some of the changes in my patch already exist in the code. Is there a way to make patch gracefully ignore the changes that have already been applied?
The -N
option doesn't do what I want. If it encounters an already applied hunk it will generate a reject file and will not apply any more hunks to that file. I want it to just ignore that hunk and continue applying the rest of the patch. The only time I want it to generate a .rej file is if a hunk can't be applied and doesn't appear to already be applied.
Is there a way to do this?
Best Answer
You'll need patchutils installed for this.
This script will split one large patch into smaller separate paches, each of them containing only one hunk for one file. You can then apply these patches with
patch --forward
.Edit: save script to
hunks.sh
, and call it: