Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply `git diff` patch without Git installed?

Tags:

git

diff

patch

How can my client apply patch created by git diff without git installed? I have tried to use patch command but it always asks file name to patch.

like image 704
Andrey Kuznetsov Avatar asked Aug 05 '10 19:08

Andrey Kuznetsov


People also ask

How do I create a git diff file?

The git diff command displays the differences between files in two commits or between a commit and your current repository. You can see what text has been added to, removed from, and changed in a file. By default, the git diff command displays any uncommitted changes to your repository.


2 Answers

git diff > patchfile

and

patch -p1 < patchfile

work but as many people noticed in comments and other answers patch does not understand adds, deletes and renames. There is no option but git apply patchfile if you need handle file adds, deletes and renames.


EDIT December 2015

Latest versions of patch command (2.7, released in September 2012) support most features of the "diff --git" format, including renames and copies, permission changes, and symlink diffs (but not yet binary diffs) (release announcement).

So provided one uses current/latest version of patch there is no need to use git to be able to apply its diff as a patch.

like image 183
Andrey Kuznetsov Avatar answered Sep 22 '22 02:09

Andrey Kuznetsov


try this:

patch -p1 < patchfile
like image 38
suppie Avatar answered Sep 22 '22 02:09

suppie