3 KiB
3 KiB
obj | repo | wiki |
---|---|---|
application | https://git.savannah.gnu.org/git/patch.git | https://en.wikipedia.org/wiki/Patch_(Unix) |
patch
patch takes a patch file patchfile containing a difference listing produced by the diff program and applies those differences to one or more original files, producing patched versions. Normally the patched versions are put in place of the originals. Backups can be made; see the -b or --backup option. The names of the files to be patched are usually taken from the patch file, but if there's just one file to be patched it can be specified on the command line as originalfile.
Usage
# To patch one file:
patch <file> < <patch-file>
# To reverse a patch:
patch -R <file> < <patch-file>
# To patch all files in a directory, adding any missing new files:
patch -i <dir> <patch-file>
Options
Option | Description |
---|---|
-b, --backup |
Make backup files. That is, when patching a file, rename or copy the original instead of removing it. When backing up a file that does not exist, an empty, unreadable backup file is created as a placeholder to represent the nonexistent file |
-d, --directory <dir> |
Change to the directory dir immediately, before doing anything else. |
--dry-run |
Print the results of applying the patches without actually changing any files |
-i, --input <patchfile> |
Read the patch from patchfile. If patchfile is -, read from standard input, the default |
--merge |
Merge a patch file into the original files. If a conflict is found, patch outputs a warning and brackets the conflict with <<<<<<< and >>>>>>> lines. |
-R, --reverse |
Reverse the patch |