XCode 4 中意外删除的 .m 文件 - 如何恢复?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8540861/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:45:58  来源:igfitidea点击:

Accidently Deleted .m File in XCode 4 - How to Recover?

xcodexcode4file-recovery

提问by Vad

In XCode 4 when I was deleting some images I had .m selected as well and oops... it's gone. I has a lot of work done for today. How can I recover? Please help. I did not use Time Machine backup recently and did not back it up somehow else. I need that one copy badly. Anything to try?

在 XCode 4 中,当我删除一些图像时,我也选择了 .m,哎呀……它不见了。我今天有很多工作要做。我怎样才能恢复?请帮忙。我最近没有使用 Time Machine 备份,也没有以其他方式备份它。我非常需要那一份。有什么可以尝试的吗?

采纳答案by theMikeSwan

First, you should always make sure the option to create a Git repo is turned on when you create a new project in Xcode. Then you should commit often, like every time you add a feature or fix a bug (maybe more often than that is there is a lot of code being written). That way you can just discard you changes and get back anything you lose.

首先,您应该始终确保在 Xcode 中创建新项目时打开了创建 Git 存储库的选项。然后你应该经常提交,就像每次添加功能或修复错误时一样(可能比这更频繁的是有很多代码正在编写)。这样,您就可以放弃更改并取回丢失的任何内容。

FOr now recovering the file depends on weather you told Xcode to move the file to the trash or not when deleting and weather or not you have emptied the trash since then. If it is in the project folder or trash just re-add the file if not you need to find a file recovery app and hope the file space hasn't been overwritten yet.

现在,恢复文件取决于天气,您告诉 Xcode 在删除时是否将文件移至垃圾箱,以及您是否从那时起清空了垃圾箱。如果它在项目文件夹或垃圾箱中,只需重新添加文件,否则您需要找到文件恢复应用程序并希望文件空间尚未被覆盖。

回答by ZunTzu

I learnt the hard way that XCode 4 deletes files instead of moving them to the trash! Disaster is just one click away.

我学会了 XCode 4 删除文件而不是将它们移到垃圾箱的艰难方法!灾难只需轻轻一按。

Obviously Time Machine or version control will not help recover recent changes.

显然 Time Machine 或版本控制无助于恢复最近的更改。

Type "undelete files on the mac" on a search engine. I managed to recover most of my data using such a piece of software.

在搜索引擎上输入“在 Mac 上取消删除文件”。我设法使用这样的软件恢复了大部分数据。

回答by zaph

If you did not empty the trash since you deleted the file move the file from the trash back into your project and re-add to the project if necessary.

如果您在删除文件后没有清空垃圾箱,请将文件从垃圾箱移回您的项目,并在必要时重新添加到项目中。

In the future at least use the snapshot feature of Xcode.

以后至少要使用 Xcode 的快照功能。

Better still use the build-in Git version control.

最好还是使用内置的 Git 版本控制。

Get a drive and use Time Machine, it protects against this kind of inadvertent deletion, it has saved me many times in a way my RAID drive won't.

获取一个驱动器并使用 Time Machine,它可以防止这种无意删除,它以一种 RAID 驱动器不会的方式拯救了我很多次。