如何创建补丁以删除文件夹并使用 diff 创建新文件夹?

How can I create a patch to delete a folder and create new folder using diff?

例如我有两个目录 oldnew。目录 old 有一个子目录 abc 目录 new 有一个子目录 cde。 我尝试使用

创建补丁
diff -ru old/ new/ > file.patch

我在 file.patch 中得到以下输出:

Only in old/: abc
Only in new/: cde

当我尝试修补文件时出现以下错误:

patch: **** Only garbage was found in the patch input.

当我尝试使用以下方法创建补丁时:

diff -ruN old/ new/ > file.patch

我空了file.patch。

有没有什么方法可以创建一个补丁,当补丁到旧版本时会删除 abc 并在旧版本中创建 cde

makepatch script is useful for this. I use this for almost all source-patches, along with diffstat. There is also applypatch(完成任务),虽然我自己不用。

GNU diff 新文件“-N”选项(过去不...)与递归选项“-r”一起使用。所以你可以使用

diff -r -N old new

我刚刚验证它适用于 diff 3.0(现在已经很旧了)。