xcode 如果未提交,如何撤消“丢弃”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11418429/
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-09-15 00:50:39  来源:igfitidea点击:

How to undo "Discard" if not committed

xcodeversion-controlatlassian-sourcetree

提问by BPL

I accidentally clicked Discard while committing my changes. So I discarded the whole file but I wanted to discard only some hunk. But I haven't clicked on Commit, I did Cancel.

我在提交更改时不小心单击了放弃。所以我丢弃了整个文件,但我只想丢弃一些大块头。但是我没有点击提交,我没有点击取消。

But now I cannot see my code in my file.

但是现在我在我的文件中看不到我的代码。

What can I do to undo the damn discard ?

我该怎么做才能撤消该死的丢弃?

Thanks in advance

提前致谢

回答by Ghazanfar Mir

I know the post is too old but I faced the similar situation and accidentally clicked "Discard" in SourceTree and lost my changes.

我知道帖子太旧了,但我遇到了类似的情况,不小心点击了 SourceTree 中的“放弃”并丢失了我的更改。

Luckily I had the IDE opened, i.e. PHPStorm, at the time. Though it had already refreshed the file I was working on and loaded the old copy after Discard, however, I did "undo" on the working file in editor and it loaded back my changes.

幸运的是,当时我打开了 IDE,即 PHPStorm。尽管它已经刷新了我正在处理的文件并在丢弃后加载了旧副本,但是,我在编辑器中对工作文件进行了“撤消”并将其加载回了我的更改。

I saved the file and got my lost changes back.

我保存了文件并找回了丢失的更改。

Just wanted to share in case others face the similar situation as mine and want to recover their changes with little presence of mind :D

只是想分享一下,以防其他人面临与我类似的情况,并且想在几乎没有精神的情况下恢复他们的变化:D

回答by Chea Sambath

For me I'm using mac when I discard file and I want to get back

对我来说,当我丢弃文件时我正在使用 mac 并且我想回来

I open that file and open with TextEditor.app

我打开那个文件并用TextEditor.app打开

on the top bar click File-> Revert To-> Browse All Version...

在顶部栏上单击文件->还原为->浏览所有版本...

Select on last save version that you want hope it can save your time.

选择您想要的上次保存版本,希望它可以节省您的时间。

Thanks and regard; sambath chea

感谢和关注;sambath chea

回答by Scott Berrevoets

I don't believe you can do anything. If you didn't commit the changes at any points, there is no way to get them back after you discard them.

我不相信你可以做任何事情。如果您在任何时候都没有提交更改,则在您丢弃它们后将无法恢复它们。

回答by JosephH

There isn't any way to get your changes back via git or sourcetree as of sourcetree 1.8.1 for Mac; see the discussion here:

从 sourcetree 1.8.1 for Mac 开始,没有任何方法可以通过 git 或 sourcetree 取回您的更改;请参阅此处的讨论:

https://jira.atlassian.com/browse/SRCTREE-2090

https://jira.atlassian.com/browse/SRCTREE-2090

(If you login to jira, you can also vote for this to be implemented!)

(如果你登录jira,你也可以投票支持这个实现!)

When I did this, I was able to get the changes back as the file was in my time machine backup.

当我这样做时,我能够恢复更改,因为文件在我的时间机器备份中。

回答by Jacob Joy

In Intellij,

在 Intellij 中,

You can check the local history and revert back.

您可以检查本地历史记录并恢复。