table of contents
- stretch 1:2.11.0-3+deb9u4
- testing 1:2.20.1-2
- stretch-backports 1:2.20.1-1~bpo9+1
- unstable 1:2.20.1-2
- experimental 1:2.22.0+next.20190701-1
GIT-APPLY(1) | Git Manual | GIT-APPLY(1) |
NAME¶
git-apply - Apply a patch to files and/or to the indexSYNOPSIS¶
git apply [--stat] [--numstat] [--summary] [--check] [--index] [--3way] [--apply] [--no-add] [--build-fake-ancestor=<file>] [-R | --reverse] [--allow-binary-replacement | --binary] [--reject] [-z] [-p<n>] [-C<n>] [--inaccurate-eof] [--recount] [--cached] [--ignore-space-change | --ignore-whitespace] [--whitespace=(nowarn|warn|fix|error|error-all)] [--exclude=<path>] [--include=<path>] [--directory=<root>] [--verbose] [--unsafe-paths] [<patch>...]
DESCRIPTION¶
Reads the supplied diff output (i.e. "a patch") and applies it to files. When running from a subdirectory in a repository, patched paths outside the directory are ignored. With the --index option the patch is also applied to the index, and with the --cached option the patch is only applied to the index. Without these options, the command applies the patch only to files, and does not require them to be in a Git repository.This command applies the patch but does not create a commit. Use git-am(1) to create commits from patches generated by git-format-patch(1) and/or received by email.
OPTIONS¶
<patch>...--stat
--numstat
--summary
--check
--index
--cached
-3, --3way
--build-fake-ancestor=<file>
When a pure mode change is encountered (which has no index information), the information is read from the current index instead.
-R, --reverse
--reject
-z
Without this option, each pathname output will have TAB, LF, double quotes, and backslash characters replaced with \t, \n, \", and \\, respectively, and the pathname will be enclosed in double quotes if any of those replacements occurred.
-p<n>
-C<n>
--unidiff-zero
Note, for the reasons stated above usage of context-free patches is discouraged.
--apply
--no-add
--allow-binary-replacement, --binary
--exclude=<path-pattern>
--include=<path-pattern>
When --exclude and --include patterns are used, they are examined in the order they appear on the command line, and the first match determines if a patch to each path is used. A patch to a path that does not match any include/exclude pattern is used by default if there is no include pattern on the command line, and ignored if there is any include pattern.
--ignore-space-change, --ignore-whitespace
--whitespace=<action>
By default, the command outputs warning messages but applies the patch. When git-apply is used for statistics and not applying a patch, it defaults to nowarn.
You can use different <action> values to control this behavior:
--inaccurate-eof
-v, --verbose
--recount
--directory=<root>
For example, a patch that talks about updating a/git-gui.sh to b/git-gui.sh can be applied to the file in the working tree modules/git-gui/git-gui.sh by running git apply --directory=modules/git-gui.
--unsafe-paths
When git apply is used as a "better GNU patch", the user can pass the --unsafe-paths option to override this safety check. This option has no effect when --index or --cached is in use.
CONFIGURATION¶
apply.ignoreWhitespaceapply.whitespace
SUBMODULES¶
If the patch contains any changes to submodules then git apply treats these changes as follows.If --index is specified (explicitly or implicitly), then the submodule commits must match the index exactly for the patch to apply. If any of the submodules are checked-out, then these check-outs are completely ignored, i.e., they are not required to be up-to-date or clean and they are not updated.
If --index is not specified, then the submodule commits in the patch are ignored and only the absence or presence of the corresponding subdirectory is checked and (if possible) updated.
SEE ALSO¶
git-am(1).GIT¶
Part of the git(1) suite09/28/2018 | Git 2.11.0 |