如何处理 GitHub 上的第一个 Pull Request?

发布于 2024-11-02 12:58:54 字数 419 浏览 1 评论 0原文

我对 Git 比较陌生。到目前为止,我的知识包括git add push commit。就是这样,到目前为止它对我来说已经足够好了。 :)

然而今天早上有人向我发送了一个拉取请求,据我所知,这意味着有人分叉了我的存储库,做了一些调整,并标记我说,“嘿 Sergio,我做了一些改进。考虑将它们作为主分支。”

我说得对吗?

https://github.com/sergiotapia/CherryTomato/pulls

如果是这样,我如何轻松地将此用户更改合并到存储库的主分支中吗?我需要触发什么命令?更重要的是,有人可以用外行术语解释这个过程会发生什么吗?

I'm relatively new to Git. My knowledge thus far includes git add push commit. That's about it, and until now it served me well enough. :)

However this morning someone sent me a pull request, which as I've read means someone forked my repository, made some tweaks and is flagging me saying, "Hey Sergio, I made some improvement. Consider them for the master branch."

Am I correct?

https://github.com/sergiotapia/CherryTomato/pulls

If so, how do I easily merge this users changes into the master branch of the repository? What commands do I need to fire? More importantly, can someone explain the process in layman terms to what has to happen?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

街角迷惘 2024-11-09 12:58:54

你的想法是正确的。如果这组更改看起来对您有用,那么您可能希望将其合并到您的存储库中。

Github 提供了一个很好的响应拉取请求的指南:https://help.github.com /articles/using-pull-requests – 我将从这里开始,看看您是否对这个过程有任何更具体的问题。

You have the right idea. if that set of changes looks useful to you then you probably want to merge it into your repository.

Github offers a nice guide to responding to pull requests: https://help.github.com/articles/using-pull-requests – I'd start with that and see if you have any more specific questions about the process.

飘过的浮云 2024-11-09 12:58:54

Github 提供了一个 Fork Queue 屏幕,允许您直接将更改拉入 Github 上的存储库中。此屏幕以绿色或粉色显示每个分叉提交,具体取决于它是否会干净地应用,并允许您在存储库中指定一个新分支以将更改合并到其中。 fork 队列的 URL 为 http://github.com///forkqueue

更新:使用以下步骤将 Pull Request 合并到您的主存储库:

$ git checkout master
$ git remote add nakor git://github.com/nakor/CherryTomato.git
$ git fetch nakor
$ git merge nakor
$ git push origin master

改编自此处的 Github 文档:http://help.github.com/pull-requests/#merging_a_pull_request

或者,您可以使用新的“合并” Pull Request”,今天添加到 Github 的一项新功能(!):https://github.com/blog/843-the-merge-button

Github provides a Fork Queue screen that allows you to pull the changes into your repo directly on Github. This screen presents each forked commit in either green or pink depending on whether it will apply cleanly, and allows you to specify a new branch in your repo to merge the changes into. The URL for the fork queue is http://github.com///forkqueue

Update: Use the following steps to merge the Pull Request into your master repository:

$ git checkout master
$ git remote add nakor git://github.com/nakor/CherryTomato.git
$ git fetch nakor
$ git merge nakor
$ git push origin master

Adapted from Github documentation here: http://help.github.com/pull-requests/#merging_a_pull_request

Alternatively, you can use the new "Merge Pull Request", a new feature added to Github today(!): https://github.com/blog/843-the-merge-button

明月夜 2024-11-09 12:58:54

GitHub 拉取请求指南中没有明确提到的一件事是如何将所述拉取请求应用于您的代码:
我希望合并这些更改:

  • 以快进的方式(即简单地将我的分支的 HEAD 移动到补丁的下一个 n 提交部分)
  • 或至少没有任何冲突(补丁仅修改/删除我在本地未触及的行或添加新行)

如果有最轻微的冲突,最好拒绝补丁,要求发送者再次提取您自己的代码,在他/她的本地解决任何冲突回购并提出新的拉取请求。
这样:

  • 他们完成工作(“他们”是向您发送“拉取请求”的人,即补丁),
  • 您将受益;)

One thing not mentioned explicitly in the GitHub pull request guide is how said pull request should be applied to your code:
I would like those changes to be merged:

  • in a fast forward manner (that is simply moving the HEAD of my branch to the next n commits part of the patch)
  • or at least without any conflict (the patch only modify/remove lines I haven't touched locally or add new lines)

If there is the slightest conflict, it is best to reject the patch, asking for the sender to pull your own code again, resolve any conflict locally in his/her repo and make a new pull request.
That way:

  • they do the work ("they" being the ones sending you "pull requests", that is patches)
  • you profit ;)
°如果伤别离去 2024-11-09 12:58:54

许多年后,出现了新的解决方案,如 此页面。在本地 git 存储库中时,请执行以下操作:

gh pr checkout PRID

其中 PRID 是拉取请求 (PR) 编号或 url(例如,“1”表示第一个 PR)。这会将 PR 中的代码作为新分支添加到本地存储库中。它使用 GitHub cli 包 中的 gh 命令,并且仅适用于活跃的 PR。

如果没有该包和/或对于不活动的 PR,您可以执行相同的操作:

git fetch origin pull/PRID/head:NewBranchName
git checkout NewBranchName

这会将 PRID 代码作为名为 NewBranchName 的新分支添加到您的本地存储库。请注意,这不需要使用提交 PR 的用户的存储库,这意味着如果用户的存储库不再存在或无响应,它也可以工作。

您现在可以在本地检查、比较、测试和编辑新分支,例如将其与 master 合并。或者,您可以使用以下命令将新分支推送到 GitHub:

git push origin NewBranchName

这允许您从新分支创建新 PR(以替换原始 PR)并对其进行审查和合并。

Many years later, there are new solutions, as found on this page. When in your local git repository, do:

gh pr checkout PRID

where PRID is the pull-request (PR) number or url (e.g. "1" for the first PR). This adds the code from the PR as a new branch to your local repo. It uses the the gh command from the GitHub cli package and only works for active PRs.

Without that package and/or for inactive PRs, you can do the same with:

git fetch origin pull/PRID/head:NewBranchName
git checkout NewBranchName

This adds the PRID code as a new branch named NewBranchName to your local repo. Note that this works without using the repository from the user who submitted the PR, which means it also works if the user('s repo) no longer exists or is unresponsive.

You can now locally check, compare, test and edit the new branch and e.g. merge it with master. Alternatively, you can push the new branch to GitHub with e.g.:

git push origin NewBranchName

This allows you to create a new PR from the new branch (to replace the original PR) and have it reviewed and merged instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文