如何撤消“放弃所有更改"?在 VS 代码/Git 中 [英] How do you undo "Discard all changes" in VS Code/Git
问题描述
我恐怕我已经知道答案了,但不管怎样..我不小心点击了 VS Code (OSX) 中的放弃所有更改",现在一个月的工作都没有了.噗.问题是,我没有正确设置 GIT,所以我还没有做任何提交.无论如何我可以找回我的工作吗?现在我的工作目录和空目录一样好..
I fear I already know the answer but here goes anyway.. I accidentally clicked "Discard All Changes" in VS Code (OSX) and now a month's worth of work is gone. Poof'd. Thing is, I didn't have GIT properly setup so I hadn't done any commits yet. Is there anyway I can get my work back? Right now my working directory is as good as empty..
我应该澄清一下,控制台日志说它做了一个git clean -f -q",这意味着文件已经消失了.但我想知道 VSCode 是否有备份、历史记录或缓存……或其他任何东西.我很绝望..
[edit] I should clarify, the console log says it did a "git clean -f -q" which would mean the files are gone. But I was wondering if VSCode maybe has a backup or history or cache.. or anything. I'm desperate..
推荐答案
总结:您的工作丢失,无法恢复.
Summary: Your work is lost, and cannot be restored.
VS 代码中的Clean All(放弃所有更改)选项基本上执行:
The Clean All (discard all changes) option in VS code essentially executes:
git clean -fd
git checkout -- .
所以 git clean -fd
是否可以撤消丢弃未提交的更改,这取决于 git 的手.不幸的是,由于未提交,更改未存储在 git 中,因此在执行 git clean -fd
后,git 将强制删除未跟踪的文件.
So it is git's hands whether git clean -fd
can undo discarding uncommitted changes. Unfortunately the changes are not stored in git since it not committed, so after git clean -fd
is executed, git will remove untracked files by force.
执行git checkout -- .
命令后,git会检出git中所有修改过的文件,作为上次提交的版本.
After executing the command git checkout -- .
, git will checkout all the modified files in git as the version of last commit.
这篇关于如何撤消“放弃所有更改"?在 VS 代码/Git 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!