如何撤消“放弃所有更改”在VS Code / Git中 [英] How do you undo "Discard all changes" in VS Code/Git

查看:16398
本文介绍了如何撤消“放弃所有更改”在VS Code / Git中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我担心我已经知道了答案,但无论如何这里都是。
我在VS Code(OSX)中意外地点击了放弃所有更改,现在一个月的工作已经没有了。 Poof'd。事情是,我没有正确安装GIT,所以我还没有做任何提交。无论如何,我可以让我的工作回来吗?现在我的工作目录是空的。



[b]
我应该澄清一下,控制台日志说它做了一个git clean -f -q这将意味着文件已经消失。但我想知道VSCode是否有备份或历史记录或缓存..或任何东西。我绝望了。

解决方案

因为VS代码中的全部清除基本上执行

  git clean -fd 
git checkout - 。

因此,如果 git clean -fd 可以取消放弃未提交的更改。



不幸的是,这些更改并没有存储在git中,因为它没有提交,所以执行这个命令后,git会清理未跟踪的文件在执行命令 git checkout - 。之后,git将签出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..

[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..

解决方案

Since Clean All (discard all changes) option in VS code essentially execute

git clean -fd
git checkout -- .

So it’s the business for git that if git clean -fd can undo discarding uncommitted changes.

Unfortunately the changes are not stored in git since it not committed, so after this command executed, git will clean untracked files by force.

After after execute the command git checkout -- ., git will checkout all the modified files in git as the version of last commit.

这篇关于如何撤消“放弃所有更改”在VS Code / Git中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆