git – Create a patch from a commit


By running the git apply command you can create a commit with changes from a text file:

git apply ~/Downloads/patch.txt

How do I create this patch file from an existing commit ?


As mentioned in the comments of the question, just use the git format-patch command according to the git manual, it can be used in several ways, but I believe the main ones are:

git format-patch <commitish_inicial>


git format-patch <commitish_inicial>..<commitish_final>

So git generates one or more files in the format 0000-algo-como-a-msg-de-commit.patch that can be applied with git apply .

Scroll to Top