bug-patch
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-patch] Renaming a file via patch


From: Andreas Grünbacher
Subject: Re: [bug-patch] Renaming a file via patch
Date: Fri, 5 Dec 2014 09:24:55 +0100

Oleg,

2014-12-05 0:46 GMT+01:00 Oleg <address@hidden>:
> Good day, I can not understand why I did not create the file 2.txt after 
> applying  the patch ?

Traditional diff / patch is not very good at renaming files; it can
only remove one file and add it under another name. The git diff
format does support proper renaming, but only GNU patch supports it so
far (not GNU diff).

Here is how to "rename" a file with traditional diff / patch:

$ mkdir a b
$ echo foo > a/1
$ echo foo > b/2
$ diff -Nur a b > ab.diff

$ mkdir c
$ echo foo > c/1
$ patch -d c -p1 < ab.diff
patching file 1
patching file 2

Here is how to achieve the same using git's diff format -- note that
this requires a somewhat recent version of GNU patch:

$ git diff -M a b > ab.diff
$ mkdir d
$ echo foo > d/1
$ patch -d d -p2 < ab.diff
patching file 2 (renamed from 1)

Andreas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]