Difference between patch and diff files

前端 未结 3 1515
暗喜
暗喜 2021-02-05 02:15

Could somebody explain me the difference between a .diff file and .patch file.

相关标签:
3条回答
  • 2021-02-05 02:55

    patch is a unified diff (-u), if you you do a: diff -u oldfile newfile, with patch command line, you can apply the differences to oldfile to become newfile somewhere else.

    0 讨论(0)
  • 2021-02-05 03:00

    There are no differences. diff utility produces a patch file which is applied using patch.

    0 讨论(0)
  • 2021-02-05 03:04

    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.

    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'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.

    0 讨论(0)
提交回复
热议问题