用于在代码审查后更新拉取请求的首选 Github 工作流程 [英] Preferred Github workflow for updating a pull request after code review

查看:32
本文介绍了用于在代码审查后更新拉取请求的首选 Github 工作流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已在 Github 上提交了对开源项目的更改,并收到了一位核心团队成员的代码审查意见.

I've submitted a change to an Open Source project on Github, and received code review comments from one of the core team members.

我想根据评论意见更新代码,然后重新提交.执行此操作的最佳工作流程是什么?根据我对 git/github 的有限了解,我可以执行以下任何操作:

I would like to update the code taking into account the review comments, and re-submit it. What is the best workflow for doing this? From my limited knowledge of git/github, I could do any of the following:

  1. 将代码更新为新提交,并将初始提交和更新后的提交添加到我的拉取请求中.

  1. Update the code as a new commit, and add both the initial and updated commit to my pull request.

不知何故(??)从我的存储库中回滚旧提交,并创建一个包含所有内容的新提交,然后为此提出拉取请求?

Somehow (??) rollback the old commit from my repository, and create a single new commit containing everything, then raise a pull request for that?

git commit 有一个修改功能,但我听说在将提交推送到本地存储库之外后不应该使用它?在这种情况下,我在我的本地 PC 上进行了更改并推送到我的项目的 github 分支.使用修正"可以吗?

git commit has an amend feature, but I've heard that you shouldn't use it after you've pushed the commit outside of your local repository? In this case I have made the change on my local PC and pushed to my github branch of the project. Would this be OK to use 'amend'?

还有什么?

似乎选项 2/3 会很好,因为开源项目在其历史上只有一次提交,它将实现所有内容,但我不知道如何做到这一点.

It seems like option 2/3 would be nice, as the open source project would only have one commit in their history which would implement everything, but I'm not sure how to do this.

注意:我不知道这是否会影响答案,但我没有在单独的分支中进行更改,我只是在 master 之上进行了提交

Note: I don't know if this affects the answer or not, but I didn't make the changes in a separate branch, I just did a commit on top of master

推荐答案

只需向拉取请求中使用的分支添加一个新提交并将该分支推送到 GitHub.拉取请求将使用额外的提交自动更新.

Just add a new commit to the branch used in the pull request and push the branch to GitHub. The pull request will automatically be updated with the additional commit.

#2 和 #3 是不必要的.如果人们只想查看您的分支合并的位置(而不是其他提交),他们可以使用 git log --first-parent 仅查看日志中的合并提交.

#2 and #3 are unnecessary. If people want to see only where your branch was merged in (and not the additional commits), they can use git log --first-parent to only view the merge commit in the log.

这篇关于用于在代码审查后更新拉取请求的首选 Github 工作流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆