1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-23 01:22:08 +02:00
tldr/pages/common/git-apply.md
Hugo Locurcio 401f0388c3
git-am, git-apply: add and tweak remote patch examples (#10019)
`curl` now uses the `-L` option to follow redirects, which is required
when applying patch files from GitHub URLs. The example was also added
to `git-am` where it works too.

The difference between `git-am` and `git-apply` was also clarified in each
command's description.
2023-04-08 15:14:32 +05:30

754 B

git apply

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. 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:

curl -L {{https://example.com/file.patch}} | git apply

  • 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}}