I have two files, x_original.txt
and x_updated.txt
.
I used the following command to obtain a patch file:
git diff --no-index x_original.txt x_updated.txt > fix_something.patch
I now want to apply this patch to a file called x.txt
.
The following is worth noting:
x.txt
is not in a git repox_original.txt
and x_updated.txt
are included in fix_something.patch
which makes no sense because these files won't exist when I'm applying the patchWhat git command can I use to apply this patch? Or another utility if necessary? And what modifications should I make to the patch file?
I found out how to do it using the patch
command:
patch -p1 x.txt fix_something.patch
This utility appears to ignore the filenames specified in the patch file, so there's no need to modify anything there.