当两个人在 SVN 下编辑同一个文件时,我实际上应该在 AnkhSVN 中“做什么”
我们的代码在SVN中。我们使用 Visual Studio 和 AnkhSVN 插件进行开发。
在 SVN 之前使用过 VSS,我习惯了锁定文件的想法,以便其他用户知道在您编辑文件时不要对其进行编辑(事实上,我认为这是源代码控制的要点,以防止因这些冲突而丢失数据)。
我被告知这种情况很少发生,并且由于另一个开发人员将您锁定而导致您无法工作的情况更为常见(这听起来像是一个可能仅适用于开发项目的某个子集的原则)。但无论如何,SVN 更好,我们正在使用它。
那么,当我编辑一个文件并签入它,发现其他用户也编辑了它时,我实际上该怎么做?
当然有比保存文件副本、恢复更改、从服务器更新它,然后将我的更改合并回 winmerge 更好的方法吗?当我右键单击该文件并单击“合并”时,我被告知应该先更新,所以这显然不是我需要的。
。
更新:部分答案
好吧,听起来我只是点击更新,然后 SVN 自动合并非冲突的更改,并且应该让 AnkhSVN 了解任何冲突的更改以允许某种解决方案。 有谁知道这在 AnkhSVN 中是如何工作的 - 我实际上会做什么?
(如果不是,我会自己尝试一下,接受当前的最佳答案,并用后半部分更新这个问题以供后代使用)。
Our code is in SVN. We develop using Visual Studio and the AnkhSVN plugin.
Having used VSS before SVN I was used to the idea of locking files so other users know not to edit it while you are (in fact I thought this was the main point of source control, to prevent lost data from these conflicts).
I've been told this rarely happens and cases where you can't work because another dev is locking you out are more frequent (which sounds like a principle that might only apply to a certain subset of dev projects). But anyway, SVN is better and we're using it.
So when I do edit a file, and go to check it in, and find out the other user has edited it too, what do I actually do?
Surely there's a better way than saving a copy of my file, reverting changes, updating it from server, then merging my changes back in with winmerge? When I right-click the file and click 'merge' I'm told I should update first, so that's obviously not what I need.
.
Update: partial answer
OK, it sounds like I just hit update, then SVN merges non-conflicting changes automatically, and should let AnkhSVN know about any conflicting changes to allow some kind of resolution. Does anyone know how this works in AnkhSVN - what I'd actually do?
(if not I'll try it myself, accept the current top answer and update this question with the second half for posterity).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实上,这正是您所需要的。
编辑:澄清一下,您需要做的就是点击该更新。您不需要制作单独的副本、还原等。从存储库更新会将这些更改与您自己的更改合并。
当您进行更新时,如果您对存储库中也已更改的文件进行了本地更改,SVN 会将存储库中的文件与本地文件合并,从而保留两组更改。
实际上,它应该自动执行您使用 Winmerge 执行的操作。
如果更改发生冲突,通常发生在同一行中,则会出现合并冲突,必须解决该冲突。不了解 AnkhSvn,我不知道在这种情况下它会做什么,但它应该有一些修复问题的方法。通常,它涉及查看 3 个文件(本地文件、存储库文件和成功合并的结果),您可以在文件的两个更改版本中选择要保留的每个部分。
更新本地副本、合并并修复所有冲突后,您可以照常提交。
Actually, that's exactly what you need.
Edit: Clarification, what you need to do is just hit that update. You don't need to make a separate copy, revert, etc. Updating from the repository will merge those changes with your own.
When you do the update, where you have local changes to a file that has also been changed in the repository, SVN will merge the file in the repository with your local file, preserving both sets of changes.
In effect, it should do what you would do with Winmerge automatically.
If the changes are conflicting, typically that they occur within the same lines, there will be a merge conflict, which has to be resolved. Not knowing AnkhSvn, I don't know what it will do in this case, but it should have some means of fixing things. Usually it involves looking over 3 files (your local file, the repository file, and the result of a successful merge) where you pick each part you want to keep from the two changed versions of the file.
After you've updated your local copy, merged and fixed any conflicts, you commit as usual.
这不是对您问题的直接回答,但我建议使用 SVN-Monitor除了 AnkhSVN 或任何其他 Subversion 客户端(如 TortoiseSVN)。
有了它,您可以查看您的存储库,并将收到存储库中的更改通知。因此,您可以看到其他开发人员在存储库中做了什么,并且可能会看到您的提交是否会与其他签入发生冲突,或者您是否可以更新本地副本而不产生任何影响/冲突
It´s not an direct answer to your question, but I would recommened to use SVN-Monitor in addition to AnkhSVN or any other Subversion client like TortoiseSVN.
With it you can watch your repository and will be notified by changes in your repository. So you can see what other devs did in the repository and probably see if your commit will conflict with other checkins or if you can update your local copy without any effect/conflict