【发布时间】:2013-03-10 16:45:42
【问题描述】:
我关注了很多文章,但我仍然不知道如何在 Cygwin 中使用 diff 和 patch
这里我在 Windows 资源管理器中创建了 2 个文件
origin.txt
one
two
three
new.txt
one
four
five
然后我 diff -u origin.txt new.txt > file.patch 导致这个
--- origin.txt 2013-03-21 15:53:20.062956800 +0700
+++ new.txt 2013-03-21 15:53:29.191869600 +0700
@@ -1,3 +1,3 @@
one
-two
-three
\ No newline at end of file
+four
+five
\ No newline at end of file
然后我patch origin.txt < file.patch 显示错误
patching file origin.txt
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file origin.txt.rej
如何克服这个问题?这与Unix和Windows文件格式有关吗?
P/S:我使用的是 CYGWIN_NT-6.1-WOW64 和 Windows 7 64bit
【问题讨论】:
-
如果您没有安装
patch,请使用:apt-cyg install patch。 (在它自己的包中称为patch。)