How to revert/recover .m file to a previous version? (autosaved blank by mistake and xcode crashed – no Source Control, no Time Machine)
I’ve tried to search for the answer but I cannot precisely define the terms without falling under wrong threads all the time.
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.
- How to keep Xcode class in sync with other projects
- Setting bundle version based on git in xcode
- Password Prompt issue when trying to connect to GitHub
- Cannot change/delete/commit/discard current branch
- Git - xcode - single project multiple developer on LAN
- . gitattributes not working
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?
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.
One Solution collect form web for “How to revert/recover .m file to a previous version? (autosaved blank by mistake and xcode crashed – no Source Control, no Time Machine)”
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.