git 有没有办法在 VS 代码中恢复到以前的提交?

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

Is there a way to revert to a previous commit in VS code?

gitvisual-studio-code

提问by Vikranth

I googled it but was unable to find the answer to the question.

我用谷歌搜索,但无法找到问题的答案。

Thanks in advance.

提前致谢。

P.S I know I can see the changes between commits and the differences in the working tree but I want to know to know how to reset to previous commit in visual studio code

PS 我知道我可以看到提交之间的变化和工作树中的差异,但我想知道如何在 Visual Studio 代码中重置为以前的提交

回答by Mark

With the source control icon selected, if you then click the ellipsis ... at the top right.

选择源代码管理图标后,如果您单击右上角的省略号 ...。

You will see a long list of available options: one is Undo Last Commit. And another is Discard All Changes.

您将看到一长串可用选项:一个是Undo Last Commit. 另一个是Discard All Changes

demo of git ellipsis commands

git 省略号命令演示

回答by jmarceli

Provided that you have GitLensextension installed you should be able to simply select "Restore" action from selected "File history" commit.

如果您安装了GitLens扩展,您应该能够简单地从选定的“文件历史记录”提交中选择“恢复”操作。

GitLens Restore file from File History

GitLens 从文件历史记录中恢复文件