简体   繁体   English

使用SVN,如何有选择地创建补丁文件?

[英]Using SVN, how do I selectively create a patch file?

I have a codebase with several changes in it that are best split up into several commits. 我有一个代码库,其中有几个更改,最好将其分成几个提交。

In git , I would use git add -p to select the changes I wanted from each file and create a commit and pull request based on those. git ,我将使用git add -p从每个文件中选择所需的更改,并基于这些更改创建提交和请求。

I'm new to SVN and I'm wondering about the best way to achieve this? 我是SVN的新手,我想知道实现此目标的最佳方法吗? It looks like I can do file-level selection, but not changes within those files? 看起来我可以执行文件级选择,但不能在这些文件中进行更改?

I'm using TortoiseSVN as my local version control tool, but I'm happy to use another tool (has to run on Windows) if there's one that will do what I want. 我使用TortoiseSVN作为本地版本控制工具,但是如果有可以满足我需要的工具,我很乐意使用另一种工具(必须在Windows上运行)。

This is something you won't get from SVN. 这是您无法从SVN获得的。 Separating changes in your working area into multiple commit can only have a file granularity. 将工作区中的更改分成多个提交只能具有文件粒度。 You can't split changes from the same file into several commits. 您不能将来自同一文件的更改拆分为多个提交。

So I'd say you should instead give a look at how git-svn works . 因此,我想您应该看看git-svn的工作原理 It allows you to use Git over an SVN repository, with some limitations. 它允许您在SVN存储库上使用Git,但有一些限制。 You'll use git dcommit to push to the SVN repository for example. 例如,您将使用git dcommit推送到SVN存储库。 You must use a rebasing strategy over merging too. 您还必须在合并中使用重新调整策略。 But otherwise, you get colored diffs, stash, rebasing, proper handling of multiple branches, proper formatting of patches by default, etc. 但是否则,您将获得彩色差异,隐藏,重新设置基础,正确处理多个分支,默认情况下正确设置补丁格式等。

If you already know git, this will give you more, for less annoyance. 如果您已经知道git,这将给您带来更多的好处,而带来的烦恼更少。

It looks like I can do file-level selection, but not changes within those files? 看起来我可以执行文件级选择,但不能在这些文件中进行更改?

This is easily possible with VisualSVN plug-in for Visual Studio 2017. The feature is called QuickCommit and it helps you partially commit selected changes in a file. 这可以通过Visual Studio 2017的VisualSVN插件轻松实现。此功能称为QuickCommit,可帮助您部分提交文件中的选定更改。

Use the Commit this Block and Commit Selection context menu commands in the Visual Studio editor. 在Visual Studio编辑器中使用“ 提交此阻止提交选择”上下文菜单命令。

Here is an animated screenshot: 这是一个动画截图:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM