Question

With a git repository setup for my iPhone app, is there a way to gain access to the last committed version of a file outside of XCode? Can I find the previous version somewhere on the hard drive, or perhaps piece the file together somehow? The current version of the file is now corrupt (see story below for how this happened if interested), and I'd very much like to retrieve the changes I made since the last time I was able to backup the files outside of git. I don't have the ability to access anything in XCode or run anything on the Mac outside of what's available through Max OS X Installer, so I'd like to access the previous version of the file if that is possible.

Story that pisses me off begins here:

On a recent 6 hour flight, I took my MAC with me on the plane, committing changes to the git about 2 times during this period. Everything functioned fine on the MAC all the way until we had to shut down all electronics at the end of the flight. At that time, I told the MAC to shutdown, but it froze instead. Wanting to avoid an airline incident, I forced the computer to shutdown by holding the power button after waiting for over a minute.

When I turned on the computer later that night, it would no longer boot, instead freezing on the Apple logo and the spinning gear. I used my install disk to bypass logging in and accessed Disk Utility, which proceeded to FAIL repairing my drive. The hard drive still mounts, so I'm able to get into my files. I accessed the absolutely essential file needed for my app, and when I opened it on my Windows machine it contained garbage. Of course most of the other files were all fine :-/

Story that pisses me off ends here.

So, I'm still trying to fix my stupid MAC, but before proceeding and possibly needing to wipe the drive, I'm trying to grab all the files I can, so any help is definitely appreciated.

Was it helpful?

Solution

To wipe out the current changes and see the most recent committed version,

git checkout HEAD .

To wipe out the current changes and see the previous committed version,

git checkout HEAD^ .
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top