2020-08-12 00:33:53 +01:00
|
|
|
# git apply
|
|
|
|
|
2023-04-08 10:44:32 +01:00
|
|
|
> Apply a patch to files and/or to the index without creating a commit.
|
|
|
|
> See also `git am`, which applies a patch and also creates a commit.
|
2020-08-12 00:33:53 +01:00
|
|
|
> More information: <https://git-scm.com/docs/git-apply>.
|
|
|
|
|
|
|
|
- Print messages about the patched files:
|
|
|
|
|
|
|
|
`git apply --verbose {{path/to/file}}`
|
|
|
|
|
|
|
|
- Apply and add the patched files to the index:
|
|
|
|
|
|
|
|
`git apply --index {{path/to/file}}`
|
|
|
|
|
|
|
|
- Apply a remote patch file:
|
|
|
|
|
2023-04-08 10:44:32 +01:00
|
|
|
`curl -L {{https://example.com/file.patch}} | git apply`
|
2020-08-12 00:33:53 +01:00
|
|
|
|
|
|
|
- Output diffstat for the input and apply the patch:
|
|
|
|
|
|
|
|
`git apply --stat --apply {{path/to/file}}`
|
|
|
|
|
|
|
|
- Apply the patch in reverse:
|
|
|
|
|
|
|
|
`git apply --reverse {{path/to/file}}`
|
|
|
|
|
|
|
|
- Store the patch result in the index without modifying the working tree:
|
|
|
|
|
|
|
|
`git apply --cache {{path/to/file}}`
|