ios 如果未提交,如何撤消 xcode 丢弃所有更改

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25308554/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 01:50:07  来源:igfitidea点击:

How to undo xcode discard all changes if not committed

iosxcodegit

提问by yong ho

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?

我有一个 iOS 项目,我有一些更改尚未提交。我错误地单击了放弃所有更改。我实际上只想丢弃特定文件的更改。但是我按错了按钮。而现在一切都过去了。如何撤消更改?

git status shows nothing.

git status 什么也没显示。

采纳答案by BHendricks

I think you are out of luck. See this answer: Accidentally reverted to master, lost uncommitted changes

我觉得你运气不好。看到这个答案: 意外恢复到主人,丢失了未提交的更改

Since you did not commit, or stage any of your files, then having reverted them means they are lost.

由于您没有提交或暂存任何文件,因此恢复它们意味着它们丢失了。

Sorry.

对不起。

回答by George Marmaridis

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

你可能不会走运。虽然 Git 帮不了你,但 Finder 或许能来救你!

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 Mnext to these files in Project Navigator indicating they include uncommited changes (the changes you previously discarded).
  1. 退出 Xcode。
  2. 打开您希望使用 TextEdit 恢复丢失的更改的文件。
  3. 转到文件 > 还原为 > 浏览所有版本...
  4. 滚动浏览可用版本。希望您将有很多可供选择。
  5. 选择一个版本并点击恢复。
  6. 对于所有必需的文件,请按照 2-5 进行操作。
  7. 启动 Xcode。您现在应该M在 Project Navigator 中看到这些文件旁边的 ,指示它们包含未提交的更改(您之前丢弃的更改)。

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 Changesby right clicking on files in the Project Navigator, instead of Discard All Changeswhich might give you all kinds of trouble.

还有一个小小的建议。如果您需要放弃更改,请通过右键单击项目导航器中的文件来使用Source Control > Discard Changes,而不是Discard All Changes,这可能会给您带来各种麻烦。

Have a nice day. :)

祝你今天过得愉快。:)

回答by Iya

If you clicked on "discard changes" before committing any changes, your project will become blank and you will find all files in your trash. There is not an whole xcode project there, but you will find all the files which have dates of when you created them. I solved my issue by getting the file I needed from trash. Then I put it back into my project.

如果您在提交任何更改之前单击“放弃更改”,您的项目将变为空白,并且您会在垃圾箱中找到所有文件。那里没有完整的 xcode 项目,但您会找到所有具有创建日期的文件。我通过从垃圾箱中获取我需要的文件解决了我的问题。然后我把它放回我的项目中。

回答by The Review Guy

I restored it by using Timeline (it's a built-in app in Mac).

我使用 Timeline 恢复了它(它是 Mac 中的内置应用程序)。

give it a try,

试一试,

Go to Timeline -> locate and select the project file in finder -> Click restore.

转到时间轴 -> 在 finder 中找到并选择项目文件 -> 单击恢复。

that's it.

就是这样。