git 从拉取请求中删除提交
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20765030/
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
git remove a commit from pull request
提问by asiniy
I'm newbie to open source contribution, so it one of my first tries.
我是开源贡献的新手,所以这是我的第一次尝试。
I developed a library (gem) called validates
: https://github.com/kaize/validates/
我开发了一个名为validates
:https: //github.com/kaize/validates/的库(gem)
I made 2 branches through git checkout -b branch_name
:
我通过git checkout -b branch_name
以下方式创建了 2 个分支:
https://github.com/kaize/validates/pull/20 & https://github.com/kaize/validates/pull/19, and make commits for them, but, you can see that ip-validator pull request have a commit Blank validator
399cdd7
.
https://github.com/kaize/validates/pull/20 & https://github.com/kaize/validates/pull/19,并为他们提交,但是,你可以看到 ip-validator pull request 有一次提交Blank validator
399cdd7
。
What I need to do to remove it from this pull request (and still place in blank validator branch)?
我需要做什么才能从这个拉取请求中删除它(并且仍然放在空白的验证器分支中)?
Please help me with make world better, guys!
请帮助我让世界变得更好,伙计们!
回答by CDub
On the ip-validator
branch, you'd do git rebase -i HEAD~2
- this will start an interactive rebase back two commits on that branch.
在ip-validator
分支上,你会这样做git rebase -i HEAD~2
- 这将启动一个交互式 rebase,返回该分支上的两个提交。
At this point, you'll get an editor open with options seen here: https://help.github.com/articles/interactive-rebase
此时,您将打开一个编辑器,其中包含以下选项:https: //help.github.com/articles/interactive-rebase
Simply put, to remove that commit, just delete the commit line in the editor, save that editor file, and git will create a new commit without the commit you removed.
简单地说,要删除该提交,只需删除编辑器中的提交行,保存该编辑器文件,git 将创建一个新提交,而不会删除您删除的提交。