Files
tldr/pages/common/patch.md
T
2026-06-29 11:18:18 +07:00

743 B

patch

Patch a file (or files) with a diff file. Note that diff files should be generated by the diff command. More information: https://manned.org/patch.

  • Apply a patch using a diff file (filenames must be included in the diff file):

patch {{[-i|--input]}} {{patch.diff}}

  • Apply a patch to a specific file:

patch {{[-i|--input]}} {{patch.diff}} {{path/to/file}}

  • Patch a file writing the result to a different file:

patch {{[-i|--input]}} {{patch.diff}} {{path/to/input_file}} {{[-o|--output]}} {{path/to/output_file}}

  • Apply a patch to the current directory:

patch {{[-i|--input]}} {{patch.diff}} {{[-p|--strip]}} 1

  • Apply the reverse of a patch:

patch {{[-i|--input]}} {{patch.diff}} {{[-R|--reverse]}}