如何从拉取请求中删除提交 [英] How to remove commits from a pull request
问题描述
我做了一个拉取请求,但是之后我在本地对项目进行了一些提交,最终污染了我的拉取请求,我试图删除它,但是没有任何运气.
I did a pull request but after that I made some commits to the project locally which ended polluting my pull request, I tried to remove it but without any luck.
我在StackOverflow上发现了一些类似的问题,但是我无法应用其中的内容. 这是我在GitHub上的第一个拉取请求,所以这一切如何工作对我来说有点奇怪.
I found some similar questions on StackOverflow but I can't apply what's in there. It's my first pull request on GitHub so it's kinda strange to me how all of this works.
突出显示的提交是我需要保留并删除所有其他内容的提交. 这是历史上的第四次提交,因为我做了一些合并工作.
The highlighted commit is the one I need to keep and remove all the other stuff. It becomes the fourth commit in the history because I make some merge stuff.
我的git日志
有人可以解释发生了什么以及如何解决此问题吗?
Can someone please explain what's going on and how to fix this problem?
推荐答案
您有几种技巧可以做到这一点.
You have several techniques to do it.
这篇文章-阅读了有关还原将详细说明我们想要做什么以及如何做.
This post - read the part about the revert will explain in details what we want to do and how to do it.
这是解决问题的最简单方法:
Here is the most simple solution to your problem:
# Checkout the desired branch
git checkout <branch>
# Undo the desired commit
git revert <commit>
# Update the remote with the undo of the code
git push origin <branch>
revert命令将使用原始提交的撤消创建一个新的提交.
The revert command will create a new commit with the undo of the original commit.
这篇关于如何从拉取请求中删除提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!