简体   繁体   English

更改 GitHub 拉取请求中的提交消息

[英]Changing commit message in GitHub pull request

I have pushed some code for review and have been asked to change couple of my commit messages.我推送了一些代码以供审查,并被要求更改我的一些提交消息。

I tried doing git rebase -i HEAD~5 since it isn't my latest commit which needs to be changed.我尝试执行git rebase -i HEAD~5因为它不是我需要更改的最新提交。

Upon making changes, I now see that my branch has been diverged.进行更改后,我现在看到我的分支已经发散了。 What would have been the correct approach here?这里的正确方法是什么?

I am not that confident, so would probably end up creating a new pull request all together.我没有那么自信,所以可能最终会一起创建一个新的拉取请求。 But, I would have liked to change in same pull request so that review comment history would have been retained.但是,我希望在同一个拉取请求中进行更改,以便保留评论评论历史。

You don't need to create a new pull request.您不需要创建新的拉取请求。 You can simply make the changes to your commit messages (or any other changes you'd like to make to your commits) and force-push them to the same branch on the remote.您可以简单地对提交消息进行更改(或您想要对提交进行的任何其他更改)并强制将它们推送到远程的同一分支。 The pull request will be updated with the new commit contents.拉取请求将使用新的提交内容进行更新。 You can do that either by specifying the -f option when you run git push or putting a plus sign ( + ) in front of the branch name when pushing.您可以通过在运行git push时指定-f选项或在git push时在分支名称前放置加号 ( + ) 来实现。

Usually your CI system will realize that your commits have changed and run again on the new commits.通常,您的 CI 系统会意识到您的提交已更改并在新提交上再次运行。 So if your old commits didn't meet the standard for whatever reason, that shouldn't be a factor in whether your new commits pass.因此,如果您的旧提交由于某种原因不符合标准,则这不应成为您的新提交是否通过的一个因素。

The benefit to updating the pull request is that it retains any description you've provided and any comments folks have provided on previous versions.更新拉取请求的好处是它保留了您提供的任何描述以及人们对以前版本提供的任何评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM