创建并应用补丁

2026-02-02 21:06:00 欧冠世界杯

创建一个补丁文件首先你需要做出修改并测试这个修改的内容。然后在父目录上使用TortoiseSVN → 创建补丁...代替TortoiseSVN → 提交...。

图 4.61. 创建补丁的对话框

现在你可以选择要包含在补丁中的文件了,就像你要做一个完整的提交一样。这样会产生一个单一的文件,该文件包括一份自从最后一次从仓库更新后你对所选择文件做的全部修改的摘要。

在这一对话框中,纵列和在 检查修改对话框中的纵列同样是可以定制的。更多细节请阅读“本地与远程状态”一节

By clicking on the Options button you can specify how the patch is created. For example you can specify that changes in line endings or whitespaces are not included in the final patch file.

你可以创建包含对不同文件集合修改的相互独立的补丁。当然如果你创建了一个补丁文件,对于同一份文件的更多修改会创建另外一个补丁文件,第二份补丁文件包含了全部的修改。

你可以用一个自己选择的文件名来保存这个补丁文件,补丁文件可以有任意的扩展名,但是按人一般习惯,人们都是用.patch或者.diff作扩展名,你现在已经做好提交你的补丁文件的准备了。

提示Do not save the patch file with a .txt extension if you intend to send it via email to someone else. Plain text files are often mangled with by the email software and it often happens that whitespaces and newline chars are automatically converted and compressed. If that happens, the patch won't apply smoothly. So use .patch or .diff as the extension when you save the patch file.你也可以将补丁保存到剪贴板,而不是文件。这样你可以粘贴到电子邮件中,让他人审核。或者你在机器上有两个工作副本,想将修改传递到另外的副本。在剪贴板上的补丁就是为这些操作提供便利。

If you prefer, you can create a patch file from within the Commit or Check for Modifications dialogs. Just select the files and use the context menu item to create a patch from those files. If you want to see the Options dialog you have to hold shift when you right click.