且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何撤消“放弃所有更改"?在 VS 代码/Git 中

更新时间:2021-07-22 10:49:07

总结:您的工作丢失,无法恢复.

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.