Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Patch (Unix)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Usage examples== To create a patch, one could run the following command in a shell: <syntaxhighlight lang="console"> $ diff -u oldFile newFile > mods.diff # -u tells diff to output unified diff format </syntaxhighlight> To apply a patch, one could run the following command in a shell: <syntaxhighlight lang="console"> $ patch < mods.diff </syntaxhighlight> This tells patch to apply the changes to the specified files described in <code>mods.diff</code>. Patches to files in subdirectories require the additional <code>-p''number''</code> option, where ''number'' is 1 if the base directory of the source tree is included in the diff, and 0 otherwise. Patches can be undone, or reversed, with the '<code>-R</code>' option: <syntaxhighlight lang="console"> $ patch -R < mods.diff </syntaxhighlight> In some cases when the file is not identical to the version the diff was generated against, the patch will not be able to be applied cleanly. For example, if lines of text are inserted at the beginning, the line numbers referred to in the patch will be incorrect. patch is able to recover from this, by looking at nearby lines to relocate the text to be patched. It will also recover when lines of '''context''' (for context and unified diffs) are altered; this is described as '''fuzz'''.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)