Recently I had to create patch from a local commit to apply a totally different branch and on a different clone. Obviously I couldn't use git cherry-pick so I tried and found out to create a patch from a GIT commit.

It all comes down to using git format-patch command and the patch shell command :

create patch from last commit (local or not)

git format-patch -1 HEAD
# creates a patch file in the root directory of the GIT clone : lest say some_file.patch

apply patch

patch -p1 < [path_to]/some_file.patch

Published

Category

tips

Tags

Contact