如何恢复 SVN 客户端删除的文件?
我刚刚从 SVN 更新,我的一个文件现在消失了……当然它没有提交,因为我知道我需要先更新+合并。 我想也许那个人重命名了该文件,这意味着我的 SVN 客户端删除了我的文件。
我正在使用 VC++ 2008 & 视觉SVN。
求助...作为参考,这种事情应该如何避免? 提交之前不应该先更新吗?
I just updated from SVN, and one of my files has now disappeared... of course it wasn't committed because I knew I needed to update+merge first. I think maybe the guy renamed the file which means my SVN client deleted my file.
I'm using VC++ 2008 & Visual SVN.
Help... and for reference how is this kind of thing supposed to be avoided? Aren't you supposed to update before committing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您在 VS 中查找该文件,该文件很可能仍然存在于您的目录中,但只是不再在项目中引用(因为 VS 只会显示项目中的文件)。 如果该文件已重命名,这可能就是您无法再在 Visual Studio 中找到它的原因。 我会检查该文件曾经存在的实际目录。
如果不存在,您可以通过单击包含的目录并恢复到包含该文件的先前版本(文件删除是对目录的操作)来从存储库中检索旧文件。
如果有修改,则不应删除该文件的本地副本。 这种类型的事情很烦人,但希望不会经常发生(您重命名文件的频率如何?)。 当然,这也正是您应该在提交之前更新的原因。 在这种情况下,您需要手动将对旧文件所做的更改合并到新文件中,并确保它仍然可以编译。
If you are looking for the file in VS, it is likely that the file still exists in your directory, but is simply no longer referenced in the project (Since VS will only show you files in your project). If the file was renamed, that is likely why you can no longer find it in Visual Studio. I would check the actually directory where the file used to exist.
If it is not there, you can retrieve the old file from the repository by clicking on the containing directory and reverting to a previous revision that contains the file (file deletes are operations on the directory).
Your local copy of the file should not be deleted if there are modifications. This type of thing is annoying, but hopefully doesn't happen very often (how often do you rename files?). Of course, this is also exactly why you should update before committing. In this case, you need to manually merge the changes you made to the old file into the new file and make sure that it all still compiles.
如果您更改了文件,SVN 应该备份该文件。 检查是否存在以“.”开头的文件 并将修订版本放在您更改的文件所在目录的名称中。
如果不是这种情况,请检查 Visual SVN 中的设置。 或者 Visual SVN 可能不这样做。 尝试使用TortoiseSVN。
SVN should backup the file if you changed it. Check if there is a file which begins with "." and has the revision somewhere in the name in the directory where your changed file is supposed to be.
If that is not the case, check your settings in Visual SVN. Or maybe Visual SVN doesn't do this. Try TortoiseSVN instead.
这正是几周前发生在我身上的事情。 当我执行“更新”而不是“提交”时,我很累。 我的工作丢失了,我可以使用取消删除工具恢复其中一些。
This exactly happened a few weeks ago to me. I was tired when I did "update" instead of "commit". My work was gone, I could recover some of it with Undelete tool.
答案向您展示如何恢复文件,但更重要的是问题的第二部分:如何避免此类事情?
为此,您可以锁定文件。 这意味着您希望不受干扰地处理该文件。 SVN 不允许任何其他用户提交锁定的文件。 这也包括删除。
The answers show you how to restore your file, but more important is your second part of your question: how to avoid such things?
For this you can lock files. This means you want to work undisturbed on this file. SVN will not allow any other user to commit to a locked file. This includes deletion as well.