补丁文件和差异文件之间的区别 [英] Difference between patch and diff files
问题描述
有人可以解释一下 .diff 文件和 .patch 文件之间的区别.
Could somebody explain me the difference between a .diff file and .patch file.
推荐答案
重要的是文件的内容,而不是扩展名.这两个扩展都暗示某种diff实用程序(diff
,git diff
,git format-patch
,svn diff
)产生了输出.
What matters is the content of the file, not the extension. Both of those extensions imply that some sort of diff utility (diff
, git diff
, git format-patch
, svn diff
) produced the output.
许多diff实用程序都会产生可通过patch
命令应用的输出.您经常需要对patch
使用-d
和-p
选项,以使路径正确匹配(条带前缀,名称目标目录).如果您看到在线分发的文件中的这些扩展名之一,则几乎可以肯定地表明它与patch
兼容.
Many diff utilities produce output which can be applied by the patch
command. You will frequently need to use the -d
and -p
options to patch
in order to get the paths matched up right (strip prefix, name target directory). If you see one of those extensions on a file distributed online, it's almost certainly an indication it's compatible with patch
.
Git的diff输出与patch兼容,但我相信svn的不兼容.当然,由git diff
生成的普通补丁可能最好由git apply
应用,而由git format-patch
生成的补丁专门设计用于git-am
.
Git's diff output is compatible with patch, but I believe svn's is not. Of course, plain patches generated by git diff
are probably best applied by git apply
, and patches generated by git format-patch
are designed for use with git-am
.
这篇关于补丁文件和差异文件之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!