Search code examples
xcodegitcommitrollbackgit-checkout

Undoing a single-file Git Checkout


So, I am working on a project with XCode. Happily, I found out that it keeps an Git repository within every project. So, after a mistake on a code, i just used

git checkout aux.c

to move back from theses mistakes. Unfortunately, as i just found out, Xcode does not auto-commit, so, I ended up with a blank file. I didn't commited anything after this, but still can't figure out how to undo this checkout.


Solution

  • In fact, undoing a first commit on git is impossible. So, if you are running Xcode, commit manually frequently.

    But, there is another way.

    If you are running OS X 10.7 Lion or latter (not sure about Snow Leopard), you can try to use the versions feature from OS X to recover any file. Too late for me, but it should work