使用反向补丁推送后撤消 Git 提交?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6441902/
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
Undo a Git commit after push using reverse patch?
提问by Dziamid
I've pushed a commit and I want to revert changes introduced by this commit by applying and committing a reversed patch. How do I do it?
我已经推送了一个提交,我想通过应用和提交一个反向补丁来还原这个提交引入的更改。我该怎么做?
采纳答案by Kris K.
Sounds like you want to use git-revert.
听起来您想使用 git-revert。
https://www.kernel.org/pub/software/scm/git/docs/git-revert.html
https://www.kernel.org/pub/software/scm/git/docs/git-revert.html
回答by pilif
Use
用
git revert HEAD
This will create a patch that reverts the last commit and commit that patch as a new commit.
这将创建一个恢复上次提交的补丁并将该补丁作为新提交提交。
If you want to revert a specific earlier version, use
如果要恢复特定的早期版本,请使用
git revert <revision>
回答by Amit
simply use
简单地使用
for committed file:
对于提交的文件:
git revert <SHA1 ID>
for non-committed file:
对于未提交的文件:
git reset --hard HEAD