在 Visual Studio 2015 中,如何在 Git 中反转/撤消提交?

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

In Visual Studio 2015 how to reverse/undo a commit in Git?

gitvisual-studioazure-devops

提问by Edvaldo Silva

I have a commit done by a developer in the remote Git repository hosted in VSTS that needs to be rolled back. From Visual Studio, without going to the command prompt or how to revert the commit?

我有一个开发人员在 VSTS 中托管的远程 Git 存储库中完成的提交,需要回滚。在 Visual Studio 中,不进入命令提示符或如何恢复提交?

I want to undo the commit through Visual Studio without using a command prompt.

我想在不使用命令提示符的情况下通过 Visual Studio 撤消提交。

回答by Edward Thomson

Open the "Changes" tab in Team Explorer. Select "Actions", then "View History" to view the history of the repository. Identify the commit that you want to revert, right-click on it and select "Revert" from the context menu.

在团队资源管理器中打开“更改”选项卡。选择“操作”,然后选择“查看历史记录”以查看存储库的历史记录。确定要还原的提交,右键单击它并从上下文菜单中选择“还原”。

Revert

恢复

回答by AllenKll

Selected answer is not correct. In order to undo a commit you need to select reset, not revert. Revvert will make a new commit with code contained in previous commit. Where reset will actually delete the commits after the selected version.

所选答案不正确。为了撤消提交,您需要选择重置,而不是还原。Revvert 将使用先前提交中包含的代码进行新的提交。其中 reset 将实际删除所选版本之后的提交。