Reputation: 123
I generated a patch from the master
branch and would like to apply it to a secondary branch but the error, I believe, happens because it was created by the master
branch patch:
error: patch failed: src/projects/file.py:16
error: src/projects/file.py: patch does not apply
Upvotes: 2
Views: 674
Reputation: 281606
According to git apply docs
For atomicity, git apply by default fails the whole patch and does not touch the working tree when some of the hunks do not apply.
You can make use of --reject
option to apply the parts of the patch that are applicable, and leave the rejected hunks in corresponding *.rej
files.
Also When applying a patch, ignore changes in whitespace in context lines if necessary. Context lines will preserve their whitespace, and they will not undergo whitespace fixing regardless of the value of the --whitespace option.
You can run patch with the following command then
git apply --reject --ignore-space-change file.path
Upvotes: 2