How to produce a patch file for a specific git commit?

Posted on

How to produce a patch file for a specific git commit so that the changes in that commit can be emailed/sent?

git show 550a38b52

generate a quite close content while it is not exactly a patch.

You can use this command

git format-patch -1 550a38b52

It will generate a file like 0001-<commit-title>.patch in the current directory.

The common commit id and string can be used such as HEAD.

For how to apply the patch,

patch -p1 < 0001-commit-title.patch

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.