git-apply
TLDR
Apply a patch
$ git apply [patch.diff]
Check if patch applies$ git apply --check [patch.diff]
Apply with stats$ git apply --stat [patch.diff]
Reverse a patch$ git apply --reverse [patch.diff]
Apply to index$ git apply --cached [patch.diff]
SYNOPSIS
git apply [options] patches
DESCRIPTION
git apply applies patches to files and/or the index. Unlike git am, it works with raw diff output without email formatting, making it suitable for patches generated by git diff.
The command can apply patches to the working tree, index, or both. It supports checking patches without applying and showing statistics. Reverse application enables undoing patches.
git apply handles unified diff format patches for code changes.
PARAMETERS
PATCHES
Patch files to apply.--check
Check if patch applies cleanly.--stat
Show diffstat instead of applying.--reverse, -R
Apply patch in reverse.--cached
Apply to index only.--3way
Attempt 3-way merge.-v, --verbose
Report progress.--help
Display help information.
CAVEATS
Does not create commits. Use git am for patch series. May fail on binary files without appropriate handling.
HISTORY
git apply is a core Git command for patch application, providing lower-level functionality than git am.


