如何在Windows上创建补丁文件?
在 Windows 上,我有两个源文件,想要创建一个具有差异的补丁,例如 这个。 但我不确定这个补丁是什么格式以及使用什么应用程序来创建它? GNU diff 输出与我在上面的链接中看到的补丁有很大不同。
On windows, I have two source files and want to create a patch with difference, like this one.
But I'm unsure, what format this patch is and what app to use in order to create it? GNU diff output is very different from the patch I can see in the link above.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
尝试 WinMerge。您将在“工具”菜单中找到补丁生成器。
Try WinMerge. You'll find a patch generator in the "Tools" menu.
谢谢,PhiLho 和卢卡什! UnxUtils 中的 diff 程序在 Windows 7 下可以很好地生成补丁文件:
同样,UnxUtils 的补丁程序也可以很好地应用补丁:
Thanks, PhiLho & Lukáš! The diff program from UnxUtils works great under Windows 7 to generate the patch file:
Likewise, the patch program from UnxUtils works great to apply the patch:
输出格式称为“统一差异”,可以使用
diff -u
生成。The output format is called "unified diff", it can be generated using
diff -u
.WinMerge 是 Windows 上最好的工具。
要创建补丁文件,您需要执行以下操作:
-- 在此打开要为其生成补丁文件的文件。
-- 这里指定补丁文件的保存路径。 WinMerge 将为您保存补丁文件。
WinMerge is the best tool for windows.
To create a patch file, you need to do the following:
-- Here you open the files for which you are generating patch file.
-- Here you specify the path where to save the patch file. And WinMerge will save patch file for you.
WinMerge (http://winmerge.org/) 正是您所需要的。您还可以使用此工具比较整个文件树,这对于某些人来说绝对是必备的。
WinMerge (http://winmerge.org/) is what you need. You also can compare whole file trees with this tool, which is an absolute must-have for some people.
UnxUtils 软件包为 Windows 提供了许多有用的 Unix 工具,对 Windows 安装的影响最小(解压缩、添加位置到路径、使用它)。
它有一个 diff.exe
The UnxUtils package offers lot of useful Unix tools for Windows, with a minimal impact on Windows installation (unzip, add location to path, use it).
It has a diff.exe
在 Beyond Compare 4 中,您可以通过选择“会话”> 来生成统一差异。 “文本比较报告...”菜单项,然后为布局选择“补丁”,为补丁样式选择“统一差异”。然后将输出保存到文件或剪贴板。
In Beyond Compare 4 you can generate a unified diff by selecting the 'Session' > 'Text Compare Report...' menu item and then selecting 'Patch' for the layout and 'Unified diff' for the patch style. Then save the output to file, or to the clipboard.
我还制作了一个 工具 来在两组变更集之间生成补丁文件(如 WinMerge html 格式) /folders/commits(作为从 github 或 azure 下载的 zip 或只是位于驱动器中的文件夹),因为目前 WinMerge 不支持从命令行生成路径文件以支持自动化。
像这样使用它:
或
I've also made a tool to generate patch files (like WinMerge html format) between two sets of changesets/folders/commits (as a zip downloaded from github or azure or just folders sitting in your drive) since currently WinMerge does NOT support path file generation from command-line to support automation.
use it like:
or