重命名文件:Visual Studio 与版本控制
重命名文件的问题是,如果您想利用 Visual Studio 重构,您确实需要在 Visual Studio 内部进行。
但大多数(不是全部*)版本控制系统也希望成为进行重命名的系统。
一种解决方案是使用集成源代码控制,但这并不总是可用,而且在某些情况下非常笨重。
我个人更喜欢在 Visual Studio 之外单独使用源代码管理,但我不确定如何处理文件重命名的问题。
那么,对于那些使用 Visual Studio 的人来说,您使用哪种源代码管理?您是否使用 VS 集成(哪一个?),否则如何解决此重命名问题?
(* git 足够聪明,可以自己解决问题)
The problem with renaming files is that if you want to take advantage of Visual Studio refactoring, you really need to do it from inside Visual Studio.
But most (not all*) version control system also want to be the ones doing the renaming.
One solution is to use integrated source control, but this is not always available, and in some cases is pretty clunky.
I'd personally be more comfortable using source control separately, outside of Visual Studio, but I'm not sure how to manage this question of file renames.
So, for those of you that use Visual Studio, which source control do you use? Do you use a VS integration (which one?) and otherwise, how do you resolve this renaming problem?
(* git is smart enough to work it out for itself)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我使用 SVN(TortiseSVN 作为客户端)并大量使用提交对话框中的 修复移动 命令。这允许我在 VS 中重命名文件,并在准备好提交以保留版本历史记录时解决重命名问题。
至于使用 VS 集成,和你一样,我发现所有 VS 集成都很笨拙,所以不使用它。
I use SVN (TortiseSVN as the client) and use the Repair Move command from the commit dialog heavily. This allows me to rename the files within VS and resolve the rename when I'm ready to commit to keep version history.
As far as using the VS integration, like you, I find all VS integration clunky and do not use it.
Mercurial 通常更喜欢通过
hg rename
进行重命名,但它也可以使用hg addremove -s 100
(如果你想的话,可以使用小于 100 的值来检测来自外部源的重命名)将重命名与更改相匹配),因此很明显,您可以让 VS 进行重命名并让 Mercurial 赶上 addremove。mercurial usually prefers to do the renaming via
hg rename
however it can also detect renames from an outside source by usinghg addremove -s 100
(or less than 100 if you want to match a rename with alterations) so clearly you can let VS do the rename and get mercurial to catchup with addremove.我们使用SVN(确切地说是TortoiseSVN),我总是为重命名问题而烦恼。我发现的最简单的解决方案是从项目中删除文件,通过 TSVN 重命名它们并将它们添加回项目中。您必须手动更新包含重命名的头文件,但是使用查找和替换这相对容易。
We use SVN (TortoiseSVN to be exact), and i am always bothered with the renaming problem. The simplest solution i've found is to remove the files from the project, rename them via TSVN and add them back to the project. You have to manually update includes for renamed header files, but this is relatively easy using find&replace.
我们使用 Team Foundation Server,它可以正常工作。我还发现,改用完全集成的客户端改进了我的工作流程,因为我不需要在应用程序之间切换来完成琐碎的任务。
We use Team Foundation Server, and it works with no problems. I've also found that moving to using a fully integrated client has improved my workflow, as I don't need to flip between applications just to do trivial tasks.
我们开发“Plastic SCM”和 Visual Studio 包支持移动操作< /a>.但我明白你的观点,我越来越接受这样的想法:没有插件/包,然后让版本控制在幕后工作,只需检测发生的情况,而无需“插入”IDE。事实上,我们正在为下一个版本努力......
We develop "Plastic SCM" and the Visual Studio Package supports move operations. But I see your point, I'm getting more and more comfortable with the idea of not having plugins/packages and then have the version control working behind the scenes and simply detecting what happened without having to be "plugged in" into the IDE. In fact we're working on it for next release...
除了上述建议之外,对于 Visual Studio 2008,我发现对从 VS 内重命名的任何文件进行所有全局更改后,包括右键单击文件并重命名它,以及全局搜索和替换所有字符串,替换旧的文件名与新文件名一样,如果该文件是初始启动文件,则必须右键单击并选择“设置为默认页面”。否则,您很可能会收到“找不到资源”的消息。运行时出错。
Besides the above advice, for Visual Studio 2008 I found that after making all global changes to any file being renamed from within VS, including right clicking the file and renaming it, as well as a global search and replace for all strings, replacing the old file name with the new file name, you must, if the file is the initial startup file, right click and select it as "set as default page". Otherwise you'll may well get the "The resource cannot be found." error on runtime.