git 我可以直接在 GitHub 上恢复提交吗?

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

Can I revert commits directly on GitHub?

gitgithub

提问by phocks

It seems like you can do just about everything else directly on GitHub using the web interface, like edit and create and delete files, but I am unable to find a way to revert a commit, like you can in the GitHub local apps (Windows, and Mac) and like you can do on the git command line.

似乎您可以使用 Web 界面直接在 GitHub 上执行几乎所有其他操作,例如编辑、创建和删除文件,但我无法找到恢复提交的方法,就像您在 GitHub 本地应用程序(Windows、和 Mac),就像你可以在 git 命令行上做的那样。

I'm just wondering am I just missing something. Is the revert button hidden?

我只是想知道我是否错过了一些东西。恢复按钮是否隐藏?

I tried searching online and came across something that seemed to suggest that this was to prevent synchronization errors when working with lots of people. Is this correct?

我尝试在网上搜索并遇到一些似乎表明这是为了在与很多人一起工作时防止同步错误的东西。这样对吗?

采纳答案by VonC

No, that feature isn't directly available on the GitHub web interface (as opposed to the "Revert" button recently added for GitHub for Mac/Windows)

不,该功能在 GitHub 网络界面上不直接可用(与最近为 Mac/Windows GitHub 添加“恢复”按钮相反)

Actually, it is for pull requests only, since June 24th, 2014:

实际上,它仅用于拉取请求,自 2014 年 6 月 24 日起:

Introducing the Revert Button

介绍还原按钮

you can easily revert a pull request on GitHub by clicking Revert:

您可以通过单击 Revert 在 GitHub 上轻松地恢复拉取请求:

https://camo.githubusercontent.com/0d3350caf2bb1cba53123ffeafc00ca702b1b164/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f68656c702f70756c6c5f72657175657374732f7265766572742d70756c6c2d726571756573742d6c696e6b2e706e67

https://camo.githubusercontent.com/0d3350caf2bb1cba53123ffeafc00ca702b1b164/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f68656c702f70756c6c5f72657175657374732f7265766572742d70756c6c2d726571756573742d6c696e6b2e706e67

You'll be prompted to create a new pull request with the reverted changes:

系统将提示您使用已还原的更改创建新的拉取请求:

https://camo.githubusercontent.com/973efae3cc2764fc1353885a6a45b9a518d9b78b/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f68656c702f70756c6c5f72657175657374732f7265766572742d70756c6c2d726571756573742d6e65772d70722e706e67

https://camo.githubusercontent.com/973efae3cc2764fc1353885a6a45b9a518d9b78b/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f68656c702f70756c6c5f72657175657374732f7265766572742d70756c6c2d726571756573742d6e65772d70722e706e67



git revertis a bit more complex to manage through the web as it can accept a range of commit.
It shouldn't be an issue in term of collaboration though: a revert adds a new commit, it doesn't change the history of existing commit.

git revert通过 Web 管理有点复杂,因为它可以接受一系列提交。
不过,就协作而言,这应该不是问题:还原会添加新提交,但不会更改现有提交的历史记录。