How to revert/recover .m file to a previous version? (autosaved blank by mistake and xcode crashed - no Source Control, no Time Machine)

霸气de小男生 提交于 2019-12-21 16:34:01

问题


I've tried to search for the answer but I cannot precisely define the terms without falling under wrong threads all the time.

What happened: Accidentally I've selected all the code inside a file.m and deleted it all. It became a full blank document. When I pressed Ctrl+Z to UNDO it, the xcode crashed.

The problem: When I reopened the xcode (after the crash) , the file was still all blank (It was autosaved seconds before the crash as a blank document) - losing all my code. I could not use UNDO to rescue me on this because it autosaved and crash.

What do I need: Is there a way to recover/revert my file to a previous state before this autosaving/crash?

Extra information: Source Control: I can't use it because the last "commit" was June 27.

Time Machine: Don't have external HD to use it. It is disabled.

Updated 1: I've pressed the button "discard last change" and the file.m reverted to the file saved June 27. So, one more problem: Lose all the months of work up until now.

Update 2: I've found the solution, and posted below. But I need to wait until tomorrow to accept it as answer.

Update 3: I've reedited the text to clarify my problem.


回答1:


Oh! I fix it. I've opened the file.m with TextEdit. Then I browse to: File > Revert To> Browse All Versions

It led me to a place with all saved versions of the file, where I could search with a timeline the exact moment I need.

I've find the version previous to the blank/crash moment, and copied the text, paste it at file.m on xcode( also saved, commit it to source control for safety) and everything is ok now. I could recover all my code again.



来源:https://stackoverflow.com/questions/18700087/how-to-revert-recover-m-file-to-a-previous-version-autosaved-blank-by-mistake

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!