如何取回我的SVN客户端删除的文件?

时间:2021-07-20 23:12:35

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.

我刚从SVN更新,我的一个文件现在已经消失了...当然它没有提交,因为我知道我需要先更新+ merge。我想也许那个人重命名了这个文件,这意味着我的SVN客户端删除了我的文件。

I'm using VC++ 2008 & Visual SVN.

我正在使用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?

帮助...并参考如何避免这种事情?你不应该在提交之前更新吗?

4 个解决方案

#1


1  

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.

如果您在VS中查找文件,则该文件可能仍存在于您的目录中,但在项目中不再引用(因为VS只会向您显示项目中的文件)。如果文件已重命名,这可能是您无法再在Visual Studio中找到它的原因。我会检查文件曾经存在的实际目录。

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.

如果有修改,则不应删除该文件的本地副本。这种类型的东西很烦人,但希望不会经常发生(你多久重命名一次文件?)。当然,这也是您在提交之前应该更新的原因。在这种情况下,您需要手动将对旧文件所做的更改合并到新文件中,并确保它们仍然可以编译。

#2


0  

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.

如果您更改了文件,SVN应备份该文件。检查是否有以“。”开头的文件。并且在您更改的文件应该在的目录中的名称中的某处进行修订。

If that is not the case, check your settings in Visual SVN. Or maybe Visual SVN doesn't do this. Try TortoiseSVN instead.

如果不是这种情况,请检查Visual SVN中的设置。或者Visual SVN可能不这样做。请尝试TortoiseSVN。

#3


0  

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.

这几周前发生在我身上。当我做“更新”而不是“提交”时,我累了。我的工作已经不见了,我可以用Undelete工具恢复一些。

#4


-3  

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.

为此,您可以锁定文件。这意味着您希望在此文件上不受干扰地工作。 SVN不允许任何其他用户提交锁定文件。这也包括删除。

#1


1  

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.

如果您在VS中查找文件,则该文件可能仍存在于您的目录中,但在项目中不再引用(因为VS只会向您显示项目中的文件)。如果文件已重命名,这可能是您无法再在Visual Studio中找到它的原因。我会检查文件曾经存在的实际目录。

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.

如果有修改,则不应删除该文件的本地副本。这种类型的东西很烦人,但希望不会经常发生(你多久重命名一次文件?)。当然,这也是您在提交之前应该更新的原因。在这种情况下,您需要手动将对旧文件所做的更改合并到新文件中,并确保它们仍然可以编译。

#2


0  

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.

如果您更改了文件,SVN应备份该文件。检查是否有以“。”开头的文件。并且在您更改的文件应该在的目录中的名称中的某处进行修订。

If that is not the case, check your settings in Visual SVN. Or maybe Visual SVN doesn't do this. Try TortoiseSVN instead.

如果不是这种情况,请检查Visual SVN中的设置。或者Visual SVN可能不这样做。请尝试TortoiseSVN。

#3


0  

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.

这几周前发生在我身上。当我做“更新”而不是“提交”时,我累了。我的工作已经不见了,我可以用Undelete工具恢复一些。

#4


-3  

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.

为此,您可以锁定文件。这意味着您希望在此文件上不受干扰地工作。 SVN不允许任何其他用户提交锁定文件。这也包括删除。