Search code examples
xcodemacostimemachine

Getting code files from Mac OS X Lion Time Machine


I'm new to working on a Mac and have had Time Machine backing up to an external HDD since I started using my MBP recently.

Today I wanted to get the code from a previous version of a file and managed to go back a few days, find the file in question, open it and find the method I wanted to copy.

However, no matter what I did I couldn't copy, cut, edit or otherwise save a version of the method. I didn't click 'Restore' as I didn't want to restore either the file or the entire mac back to that date.

In the top right of the viewing window was an 'Open in Xcode' button that did nothing.

In the end I resorted to taking a photo of my screen so I could remember the method details!

What am I doing wrong, how can I copy from a file in Time Machine, or otherwise grab from one file without having to do a big restore?

Thanks.


Solution

  • If you just want one file (or a few files) then probably the easiest way is to go into Terminal and copy it directly, e.g.

    $ cd /Volumes/Time\ Machine/Backups.backupdb/Your_Mac_name/Date_time_stamp/path
    $ cp -p my_file.m ~/Desktop/
    

    Relying on Time Machine for this kind if thing though is probably not the best idea - consider using proper source control such as git - it's very easy to set up and very easy to use and it will save you a lot of grief in the long run.