Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
793 views
in Technique[技术] by (71.8m points)

ios - How to undo xcode discard all changes if not committed

I have a iOS project that I have some changes haven't commit. I clicked discard all changes mistakenly. I actually want to only discard a specific file's changes. But I clicked wrong button. And now everything are gone. How to undo the changes?

git status shows nothing.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You might not be out of luck. Although Git can't help you, Finder may be able to come to the rescue!

If you have not turned off the Versions feature (which by default is turned on and you need a Terminal command to disable), then do the following:

  1. Quit Xcode.
  2. Open the file you wish to bring back your lost changes to using TextEdit.
  3. Go to File > Revert To > Browse All Versions...
  4. Scroll through the available versions. Hopefully you will have many available to choose from.
  5. Select a version and hit Restore.
  6. Follow 2-5 for all necessary files.
  7. Launch Xcode. You should now see the M next to these files in Project Navigator indicating they include uncommited changes (the changes you previously discarded).

Completely new files you may have created and were discarded can be found in the Trash.

Also a small piece of advice. If you are in need to discard changes, prefer using Source Control > Discard Changes by right clicking on files in the Project Navigator, instead of Discard All Changes which might give you all kinds of trouble.

Have a nice day. :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...